niceguyismad
Programmer
Hello everyone, I know how to connect to database with ADODB with classes. I need to know how to connect to it without class. little about this code. I have a form with information about patient history and patient will have many history form. I want to put a next and previous button on it. u can brown the patient history however it a error coming up Errior is "object reference not set to instance ofanobject" for that line of code If (rowIndex < rst.RecordCount - 1) Then
I am not so is it the code or connecting to database is wrong. Can someone take look and tell me what i am doing wrong please.
Dim msgString As String = "msg"
Dim sqlString As String = "SELECT * FROM(PatientHistory) WHERE (((patienthistory.patientid)= txtpatientid.Text ));"
Dim cnn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim ConnectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FHISData.mdb"
Dim Emp As New CPhistory
cnn = New ADODB.Connection
cnn.Open(ConnectString)
Dim dbHandler = New CDataDBHandler
rst = dbHandler.ExecuteSQL(sqlString, msgString)
Try
rst.MoveFirst()
Catch ex As System.NullReferenceException
rst = Nothing
End Try
If (rowIndex < rst.RecordCount - 1) Then
rowIndex += 1
Displayhistory(Emp)
End If
I am not so is it the code or connecting to database is wrong. Can someone take look and tell me what i am doing wrong please.
Dim msgString As String = "msg"
Dim sqlString As String = "SELECT * FROM(PatientHistory) WHERE (((patienthistory.patientid)= txtpatientid.Text ));"
Dim cnn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim ConnectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FHISData.mdb"
Dim Emp As New CPhistory
cnn = New ADODB.Connection
cnn.Open(ConnectString)
Dim dbHandler = New CDataDBHandler
rst = dbHandler.ExecuteSQL(sqlString, msgString)
Try
rst.MoveFirst()
Catch ex As System.NullReferenceException
rst = Nothing
End Try
If (rowIndex < rst.RecordCount - 1) Then
rowIndex += 1
Displayhistory(Emp)
End If