0

彼はすべて、私はcmsに取り組んでいますが、更新コマンドを使用してレコードを更新しようとしていますが、機能していません。

これが更新用の完全なコードです。

Dim ID, RegNo, BedNo, BedType, Charges, PatName, PatAge, PatAddr, Phone, CheckupDate, Disease, BloodGroup, Doctor, Remarks As String

    RegNo = txtRegNo.Text
    BedNo = CmbBedNo.SelectedItem.ToString()
    BedType = CmbBedType.SelectedItem.ToString()
    Charges = txtCharges.Text
    PatName = txtPatName.Text
    PatAge = txtPatAge.Text
    PatAddr = txtPatAdd.Text
    Phone = txtPhone.Text
    CheckupDate = txtDate.Text
    Disease = txtDisease.Text
    BloodGroup = cmbBloodGrp.SelectedItem.ToString()
    Doctor = cmbDoctor.SelectedItem.ToString()
    Remarks = txtRemarks.Text

    ID = txtRegNo.Text

    Dim conStudent As New OleDbConnection
    Dim comStudent As New OleDbCommand


    conStudent.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\DBProject\hspms.mdb"
    conStudent.Open()

    comStudent.CommandText = "UPDATE AdmitPt SET ID =" & ID & ", Bedcategory='" & BedType & "', BedNo=" & BedNo & ", BedCharges=" & Charges & ", PtName='" & PatName & "', PtAge=" & PatAge & ", Address='" & PatAddr & "', PhoneNo='" & Phone & "', Dates='" & CheckupDate & "', Disease='" & Disease & "', BloodGroup='" & BloodGroup & "', Doctor='" & Doctor & "', Remarks='" & Remarks & "' WHERE ID=" & RegNo

    comStudent.Connection = conStudent

    comStudent.CommandType = CommandType.Text

    If (comStudent.ExecuteNonQuery() > 0) Then
        MsgBox("record successfully updated")
    End If

    conStudent.Close()

ID、BedNo、BedCharges、Age で名前が付けられたフィールドは、データ型として Number に設定されます。

4

1 に答える 1