CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2005
    Posts
    62

    Unhappy dsn less connection to Access Database

    hi,
    i m using vb6.0 as front end & database as access. i want to create connection
    ADO,it should be dsn less. but i want to use this s/w in LAN. if i use with dsn then i ve create dsn on each machine. instead of that i will create dsn less connection. can anyone tell me what i should write in connection string. if i give hard coded path like d:/abc.mdb then machine on which this .mdb file will present there it will work, but if i installed on another pc it will not work. Basically i want to create s/w which will work in LAN. pls tell me how to write connection code.

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: dsn less connection to Access Database

    If you are actually looking for a multi-user application then I would suggest that you use SQL Server or MSDE (free download from Microsoft). If you want a DSN less connection then you will have to either hard-code the path & name of the database in the code or else save it in a file and then read it everytime you need to connect to the database from the application. A DSN less connectionstring would look like this
    Code:
    connectionString = "Provider=Microsoft.Jet.OleDB.4.0; Data Source = " & databasepath&name
    Now remember if the database is residing in a folder that is shared on the server then you will have to use the complete UNC path like \\ServerName\ShareName\DatabaseName.

  3. #3
    Join Date
    Oct 2005
    Posts
    62

    Re: dsn less connection to Access Database

    thanx Shuja Ali,
    as application is very small that's why i m using Access as database. as u suggest storing path in file. can i create one .ini file & store the path inside that file. suppose my server machine name is "minfo" & another machine is "mac1" where i m installing this s/w.
    just tell me this is the way i ve to give path.

    databasepath="\\minfo\d\"
    connectionString = "Provider=Microsoft.Jet.OleDB.4.0; Data Source = " & databasepath&abc.mdb

    this is correct way of giving path.

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: dsn less connection to Access Database

    You are almost right except that there should be a space between databasepath and he database name and the database name shouldbe in quotes, like this
    Code:
    databasepath="\\minfo\d\"
    connectionString = "Provider=Microsoft.Jet.OleDB.4.0; Data Source = " & databasepath & "abc.mdb"

  5. #5
    Join Date
    Oct 2005
    Posts
    62

    Re: dsn less connection to Access Database

    thanx Shuja for helping me.
    it was my typing mistake. but thanx a lot

  6. #6
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: dsn less connection to Access Database

    You are always welcome.

  7. #7
    Join Date
    Jul 2005
    Posts
    1,083

    Re: dsn less connection to Access Database

    Just for set it clear

    1.- DSNless connection (ODBC)-->
    "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\MYDB\TEST.MDB"

    2.- Native OLEDB Access provider --->
    "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\MYDB\TEST.MDB"

    Number 2 should perform a little better than 1

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

Featured