Results 1 to 2 of 2

Thread: Connecting to Access via ADO.Net

  1. #1

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    Smile Connecting to Access via ADO.Net

    Hi,

    I'm new to VB.Net (surprise surprise!) and am having trouble with connecting to an .mdb file. I have done it 100s of times in vb.6, so if somebody could help me i'd be most appreciative.

    Is somebody able to translate this VB.6 code into VB.Net:

    Code:
    ' Define Global Variables
    Public gconDatabase As New ADODB.Connection
    
    Public Function ConnectToDatabase()
        gconDatabase.ConnectionString = "Data Source=" & gcDatabasePath & ";" & _
                                        "Persist Security Info=False"
        gconDatabase.Provider = "Microsoft.Jet.OLEDB.4.0"
        gconDatabase.Properties("Jet OLEDB:database Password").Value = gcDatabasePassword
        gconDatabase.Open 
    end function
    ?

    thanks

    stingrae
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Like this should work...

    Code:
    Dim gconDatabase As New OleDbConnection()
    Dim gcDatabasePath As String = "D:\test.mdb"
    Dim gcDatabasePassword As String = "pass"
    
    gconDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & gcDatabasePath & ";" & _
                                    "Persist Security Info=False;" & _
                                    "Jet OLEDB:Database Password=" & gcDatabasePassword & ";"
    
    gconDatabase.Open()
    gconDatabase.Close()
    Left out the connection function in my example, but that of course does not make a difference, I guess you see the point anyway . =)

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