UPDATE和DELETE查询不包含多值字段

时间:2013-06-01 09:06:14

标签: database vb.net

这就是我正在做的事情。当患者数量为0时,它可以正常工作,但是当它增加时,假设为1,则会出现错误:“UPDATE或DELETE查询不包含多值字段”。有什么问题,请帮帮我。非常感谢你。

rs = New ADODB.Recordset
    With rs
        .Open("Select * from Doctor where DName='" & cmbDoctors.Text & "'", cn, 2, 3)

        If .Fields("Patients").Value = 10 Then
            MsgBox("All appointments had been taken. Please Select another Doctor.")
            Exit Sub
        End If
        patient = Txtname.Text
        If .Fields("Patients").Value = 0 Then
            .Fields("Patient0").Value = patient
        ElseIf .Fields("Patients").Value = 1 Then
            .Fields("Patient1").Value = patient
        ElseIf .Fields("Patients").Value = 2 Then
            .Fields("Patient2").Value = patient
        ElseIf .Fields("Patients").Value = 3 Then
            .Fields("Patient3").Value = patient
        ElseIf .Fields("Patients").Value = 4 Then
            .Fields("Patient4").Value = patient
        ElseIf .Fields("Patients").Value = 5 Then
            .Fields("Patient5").Value = patient
        ElseIf .Fields("Patients").Value = 6 Then
            .Fields("Patient6").Value = patient
        ElseIf .Fields("Patients").Value = 7 Then
            .Fields("Patient7").Value = patient
        ElseIf .Fields("Patients").Value = 8 Then
            .Fields("Patient8").Value = patient
        ElseIf .Fields("Patients").Value = 9 Then
            .Fields("Patient9").Value = patient
        End If
        .Fields("Patients").Value += 1
        .Fields("Fees").Value += txtAmount.Text
        .Update()
        .Close()
    End With

1 个答案:

答案 0 :(得分:0)

试试这个

rs = New ADODB.Recordset
  With rs
    .Open("Select * from Doctor where DName='" & cmbDoctors.Text & "'", cn, 2, 3)

    If .Fields("Patients").Value = 10 Then
        MsgBox("All appointments had been taken. Please Select another Doctor.")
        Exit Sub
    End If
    patient = Txtname.Text

    ' filter here that input is 0 to 9

    .Fields("Patient" & trim(.Fields("Patients").Value)).Value = patient

    .Fields("Patients").Value = .Fields("Patients").Value + 1
    .Fields("Fees").Value = .Fields("Fees").Value + val(txtAmount.Text)
    .Update()
    .Close()
End With