Thursday, 26 September 2013

check the update command, m i doing mistake in its syntax?

check the update command, m i doing mistake in its syntax?

his there all, i'm working on a cms, while trying the update command to
update the records, its not working.
here's m complete code for update,
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()
one thing, that the fields named with ID, BedNo, BedCharges, Age are set
to Number as data type.

No comments:

Post a Comment