Solved

Microsoft Jet OLEDB 4.0 with access 97

Posted on 2006-11-22
5
768 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now