cpx_Support
asked on
Microsoft Jet OLEDB 4.0 with access 97
I'm using Visual Basic 2005 from Visual Studio 2005
This line of code works well in some machines but in one with Windows 2000 and Access 97 it fails with a : System.NullReferenceExcept ion
I think that maybe is because Microsoft Jet OLEDB 4.0 needs Access 2000 or higer, in that case how can I write the code? Even if the user haven't Access, how it work?
Thanks
Dim strConnectionString As String = _
"Provider=Microsoft.Jet.OL EDB.4.0;" & _
"Data Source=" & _
strPathCarpetaEntorno & "entorno.mdb;"
Dim objConnection As New OleDbConnection(strConnect ionString)
Dim strSQL As String = "Select codigoasesor,asesor from asesor"
Dim objCommand As New OleDbCommand(strSQL, objConnection)
Dim objReader As OleDbDataReader
Try
objConnection.Open()
objReader = objCommand.ExecuteReader()
While objReader.Read
Me.cboAsesor.Items.Add(obj Reader.Ite m("codigoa sesor") & " " & objReader.Item("asesor"))
End While
Catch OleDbExceptionErr As OleDbException
Debug.WriteLine(OleDbExcep tionErr.Me ssage)
Catch InvalidOperationExceptionE rr As InvalidOperationException
Debug.WriteLine(InvalidOpe rationExce ptionErr.M essage)
End Try
This line of code works well in some machines but in one with Windows 2000 and Access 97 it fails with a : System.NullReferenceExcept
I think that maybe is because Microsoft Jet OLEDB 4.0 needs Access 2000 or higer, in that case how can I write the code? Even if the user haven't Access, how it work?
Thanks
Dim strConnectionString As String = _
"Provider=Microsoft.Jet.OL
"Data Source=" & _
strPathCarpetaEntorno & "entorno.mdb;"
Dim objConnection As New OleDbConnection(strConnect
Dim strSQL As String = "Select codigoasesor,asesor from asesor"
Dim objCommand As New OleDbCommand(strSQL, objConnection)
Dim objReader As OleDbDataReader
Try
objConnection.Open()
objReader = objCommand.ExecuteReader()
While objReader.Read
Me.cboAsesor.Items.Add(obj
End While
Catch OleDbExceptionErr As OleDbException
Debug.WriteLine(OleDbExcep
Catch InvalidOperationExceptionE
Debug.WriteLine(InvalidOpe
End Try
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does I have to ad to prerequisites: the "Microsoft Data Access Components"?
I don't know the line of the exception because it happen in the client machine not in my machine in debug mode. Then how can I write the code to get the line of the exception?
Thanks