Results 1 to 4 of 4

Thread: Connecting to an access database using VB.net coding.

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Location
    London, England
    Posts
    1

    Question Connecting to an access database using VB.net coding.

    Hi folks i am practicing connecting to a database using code. I am not having much success.
    The code i am using:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ' Using the connection object
    Dim connNorthwind As New OleDb.OleDbConnection
    connNorthwind.ConnectionString = "provider=microsoft.jet.oledb.4.0" & "data source=g:\my document\northwind.mdb"
    connNorthwind.Open()
    connNorthwind.Close()

    End Sub

    However i this message when i when i click on start.


    An unhandled exception of type 'System.invalidoperation'
    occurred in system.data.dll.

    Additional information:the microsoft.jet.oledb.4.0 data source=g:\mydocument\northwind.mdb' provider in not registered on the local machine.
    Could you tell me what all that is about?
    How can i cure it?
    Do you have code that i can use to connect to an access database.

    Thank you all in advance

    nigel

    | IP: Logged
    Posts: 4

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. 'Copy your database in the bin folder and change the mdb file in the code
    2. Dim MyPath As String = Application.StartupPath & "\anyfile.mdb"
    3.  Dim MyConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MyPath)
    and what's your OS ? What version of MS Access do you installed on your PC?

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    this:
    connNorthwind.ConnectionString = "provider=microsoft.jet.oledb.4.0" & "data source=g:\my document\northwind.mdb"

    should be:
    connNorthwind.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=g:\my document\northwind.mdb"

    You forgot the semicolon.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Thanks for point that out . I think I should change my glasses .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width