Solved

Microsoft Jet OLEDB 4.0 with access 97

Posted on 2006-11-22
5
773 Views
Last Modified: 2008-02-26
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.NullReferenceException

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.OLEDB.4.0;" & _
            "Data Source=" & _
            strPathCarpetaEntorno & "entorno.mdb;"
        Dim objConnection As New OleDbConnection(strConnectionString)
        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(objReader.Item("codigoasesor") & " " & objReader.Item("asesor"))
            End While
        Catch OleDbExceptionErr As OleDbException
            Debug.WriteLine(OleDbExceptionErr.Message)
        Catch InvalidOperationExceptionErr As InvalidOperationException
            Debug.WriteLine(InvalidOperationExceptionErr.Message)
        End Try

0
Comment
Question by:cpx_Support
5 Comments
 
LVL 10

Assisted Solution

by:gangwisch
gangwisch earned 125 total points
ID: 17997267
Standard security:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=;"



 Workgroup (system database):

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:System Database=system.mdw;"



 With password:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"

there are the ways to set it up. But with access 97 you may find using a data source name a little easier:

DSN:

"DSN=myDsn;Uid=myUsername;Pwd=;"

 File DSN:

"FILEDSN=c:\myData.dsn;Uid=myUsername;Pwd=;"

Good Luck
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 125 total points
ID: 17997272
What line are you getting the exception on?

Bob
0
 

Author Comment

by:cpx_Support
ID: 18001374
Two coments.
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
0
 
LVL 24

Assisted Solution

by:Jeff Certain
Jeff Certain earned 125 total points
ID: 18004276
Easy solution? Use SQL Express instead of Access :):)
0
 
LVL 34

Accepted Solution

by:
Sancler earned 125 total points
ID: 18005282
I think Access97 in fact works with Jet 3.5 rather than 4.0.  The versions are supposed to be backward-compatible, but I have read about (although never personally experienced) some problems with that.  So one thing you might try is replacing (for the offending machine) this line

           "Provider=Microsoft.Jet.OLEDB.4.0;" & _

with

           "Provider=Microsoft.Jet.OLEDB.3.5;" & _

Roger
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question