Solved

Microsoft Jet OLEDB 4.0 with access 97

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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