I havae uaed this piece of code before in other applications that I have created and it works fine, but now I am getting the following error:
"Object reference not set to an instance of an object"
This is the code that it references as being bad:
The cnPaFaPark connection is declared as a form level variable:
This is the sub that I use to open the connection, the sub works fine though:
I do not understand why I am now getting this error.
Any ideas
"Object reference not set to an instance of an object"
This is the code that it references as being bad:
Code:
If cnPaFAPark.State = ConnectionState.Closed Then This is the referenced bad code line
Call OpenParadoxFAPark()
End If
The cnPaFaPark connection is declared as a form level variable:
Code:
Private cnPaFAPark As OdbcConnection
This is the sub that I use to open the connection, the sub works fine though:
Code:
Private Sub OpenParadoxFAPark()
Dim strCnPaFAPark As String = _
"CollatingSequence=ASCII;" & _
"PageTimeout=5;" & _
"MaxScanRows=8;" & _
"DefaultDir=P:\PDATA;" & _
"FILEDSN=C:\Chester\Test_Databases\FAPark.db.dsn;DriverId=538;" & _
"ParadoxNetPath=P:\PDATA;" & _
"ParadoxUserName=admin;" & _
"UserCommitSync=Yes;" & _
"FIL=Paradox 5.X;" & _
"UID=admin;" & _
"Driver={Driver do Microsoft Paradox (*.db )};" & _
"MaxBufferSize=2048;" & _
"ParadoxNetStyle=4.x;" & _
"Threads=3;" & _
"SafeTransactions=0"
Try
// open the connection to reqtrak_data.mdb
cnPaFAPark = New Odbc.OdbcConnection(strCnPaFAPark)
cnPaFAPark.Open()
MessageBox.Show("Connection to FAPark Successful!", "Connection to Paradox")
Catch ex As Exception
// if unable to open the connection to FAPark
MessageBox.Show(ex.Message, "Opening FAPark Connection")
End Try
End Sub
Any ideas