I have this function named NotYetInRecord that checks the data if it is already existing in database(MS Access 2007).
Whenever I try to run my windows app, I always getting exception "No value given to one or more required parameters.".
Public Function NotYetInRecord(ByVal _patient As Object) As Boolean
Try
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim selectRecord As String = "SELECT RTRIM(LTRIM(PatientID)) FROM PersonnalDetail " & _
" WHERE LastNm = ? AND MiddleNm = ? AND FirstNm = ? AND BirthDate = ?"
Dim cmd As New OleDb.OleDbCommand(selectRecord, con)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("LastNm", _patient.LastNm)
cmd.Parameters.AddWithValue("FirstNm", _patient.MiddleNm)
cmd.Parameters.AddWithValue("MiddleNm", _patient.FirstNm)
cmd.Parameters.AddWithValue("BirthDate", _patient.BirthDate)
If cmd.ExecuteScalar = 0 Then
con.Close()
Return True
Else
con.Close()
_patient.ErrorMessage = "Record is already exists. Cannot add duplicate record."
Return False
End If
Catch ex As Exception
con.Close()
MsgBox(ex.Message)
End Try
End Function
Does anyone can help me to solve this error. Thanks a lot.
Whenever I try to run my windows app, I always getting exception "No value given to one or more required parameters.".
Public Function NotYetInRecord(ByVal _patient As Object) As Boolean
Try
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim selectRecord As String = "SELECT RTRIM(LTRIM(PatientID)) FROM PersonnalDetail " & _
" WHERE LastNm = ? AND MiddleNm = ? AND FirstNm = ? AND BirthDate = ?"
Dim cmd As New OleDb.OleDbCommand(selectRecord, con)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("LastNm", _patient.LastNm)
cmd.Parameters.AddWithValue("FirstNm", _patient.MiddleNm)
cmd.Parameters.AddWithValue("MiddleNm", _patient.FirstNm)
cmd.Parameters.AddWithValue("BirthDate", _patient.BirthDate)
If cmd.ExecuteScalar = 0 Then
con.Close()
Return True
Else
con.Close()
_patient.ErrorMessage = "Record is already exists. Cannot add duplicate record."
Return False
End If
Catch ex As Exception
con.Close()
MsgBox(ex.Message)
End Try
End Function
Does anyone can help me to solve this error. Thanks a lot.