Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Try
cm2 = New OleDb.OleDbCommand
With cm2
.Connection = cn
.CommandType = CommandType.Text
.CommandText = "INSERT INTO PatientData (Name, Age, ICNum, Address, Dr_Preffered, PatientID, CheckIn, RoomType, RoomNo) VALUES (@ptNam, @ptAg, @ptIC, @ptAdr, @ptDR, @ptID, @ptChkIn, @ptType, @ptRoom,)"
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ptNam", System.Data.OleDb.OleDbType.VarChar, 255, Me.txtName.Text))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ptAg", System.Data.OleDb.OleDbType.Integer, 255, Me.txtAge.Text))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ptIC", System.Data.OleDb.OleDbType.Integer, 255, Me.txtIC.Text))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ptAdr", System.Data.OleDb.OleDbType.VarChar, 255, Me.txtAddress.Text))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ptDR", System.Data.OleDb.OleDbType.VarChar, 255, Me.cmbDoctor.Text.Length))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ptID", System.Data.OleDb.OleDbType.VarChar, 255, Me.txtPtID.Text))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ptChkIn", System.Data.OleDb.OleDbType.DBDate, 255, Me.DateTimePicker1.Value))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ptType", System.Data.OleDb.OleDbType.VarChar, 255, Me.rbIP.Checked = True Or Me.rbOP.Checked = True))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ptRoom", System.Data.OleDb.OleDbType.VarChar, 255, Me.cmbRoom.Text.Length))
cm2.Parameters("@ptNam").Value = Me.txtName.Text
cm2.Parameters("@ptAg").Value = Me.txtAge.Text
cm2.Parameters("@ptIC").Value = Me.txtIC.Text
cm2.Parameters("@ptAdr").Value = Me.txtAddress.Text
cm2.Parameters("@ptDR").Value = Me.cmbDoctor.Text.Length
cm2.Parameters("@ptID").Value = Me.txtPtID.Text
cm2.Parameters("@ptChkIn").Value = Me.DateTimePicker1.Value
cm2.Parameters("@ptType").Value = Me.rbIP.Checked = True Or Me.rbOP.Checked = True
cm2.Parameters("@ptRoom").Value = Me.cmbRoom.Text.Length
cm2.ExecuteNonQuery()
MsgBox("Patient Register Successesfully.", MsgBoxStyle.Information)
Exit Sub
End With
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
What I have tried:
i thought it is because of datetimepicker..
maybe it's because of my rb