Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Access Connection Issue In VB.Net

Access Connection Issue In VB.Net

Scheduled Pinned Locked Moved Visual Basic
helpcsharpdatabase
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mayhem_rules
    wrote on last edited by
    #1

    Hi Guys, I am trying to use the following connection string, - dcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Application.StartupPath & "\Database\XYZ.mdb" Application.StartupPath provides the path to the bin folder. However, the Access Databases which I am using are in the Database folder. How should I modify the connectionstring to go one step back from the BIN folder and into the DATABASE folder. Thnx for any help. With Best Regards, Mayur

    M 1 Reply Last reply
    0
    • M mayhem_rules

      Hi Guys, I am trying to use the following connection string, - dcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Application.StartupPath & "\Database\XYZ.mdb" Application.StartupPath provides the path to the bin folder. However, the Access Databases which I am using are in the Database folder. How should I modify the connectionstring to go one step back from the BIN folder and into the DATABASE folder. Thnx for any help. With Best Regards, Mayur

      M Offline
      M Offline
      mayhem_rules
      wrote on last edited by
      #2

      Hey, I just figured out how to do it. dcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Application.StartupPath & "\..\Database\XYZ.mdb However, can anyone tell me how do you set this connection in some common module and use it throughout the application rather than making the connection in every windows form. thnx for any help. With Best Regards, Mayur

      _ D 2 Replies Last reply
      0
      • M mayhem_rules

        Hey, I just figured out how to do it. dcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Application.StartupPath & "\..\Database\XYZ.mdb However, can anyone tell me how do you set this connection in some common module and use it throughout the application rather than making the connection in every windows form. thnx for any help. With Best Regards, Mayur

        _ Offline
        _ Offline
        _NinethSense_
        wrote on last edited by
        #3

        aap.config You have to "add new item" for this. Specify the connectionstring there. Example: <configuration> <appSettings> <add key="Provider" value="MSDAORA" /> <add key="DataSource" value="DBTest" /> <add key="UserID" value="Lavanya" /> <add key="Password" value="Password" /> <add key="MailServer" value="EXCH.XYZ.COM"/> </appSettings> </configuration> or <connectionStrings> <add name="ClaimEZ.My.MySettings.BACFConnection" connectionString="Data Source=MYSERVER;Initial Catalog=MYDB;Integrated Security=True" providerName="System.Data.SqlClient" /> <add name="MyDataLayer.My.MySettings.BACFConnection" connectionString="Data Source=MYSERVER;Initial Catalog=MYDB;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> PraVeeN NinethSense.com/blog/

        1 Reply Last reply
        0
        • M mayhem_rules

          Hey, I just figured out how to do it. dcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Application.StartupPath & "\..\Database\XYZ.mdb However, can anyone tell me how do you set this connection in some common module and use it throughout the application rather than making the connection in every windows form. thnx for any help. With Best Regards, Mayur

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          You don't! Best practice to make the connection to the database only when you need to run a query or modify the tables. The rule of thumb is Connect late, Query fast, Disconnect early. You just don't maintain an open connection to the database for the life of a form or, worse yet, and entire application. With an Access database, maintaining an open connection isn't so bad. But on a real SQL server, that is a VERY expensive connection license you hanging onto and not using. Get into the habit... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups