6 Replies - 2296 Views - Last Post: 09 May 2013 - 07:07 PM Rate Topic: -----

#1 dave_mark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 15-March 13

connection string app.path

Posted 09 May 2013 - 06:17 PM

hi everyone..

i have a program which include ms access database.. my problem is about the connectionstring.. i want the access file to be movable not in permanent place.. in want the access file to be access in the folder where i put the exe of my program.. its all about the app.path.. can anyone help me convert this to app.path file..

con.ConnectionString = "Provider = Microsoft.jet.oledb.4.0;Data Source= \\db1\Software\Recruitment Database\RecDB.mdb; Jet OLEDB:Database Password=;"
con.Open()

thanks...

Is This A Good Question/Topic? 0
  • +

Replies To: connection string app.path

#2 dave_mark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 15-March 13

Re: connection string app.path

Posted 09 May 2013 - 06:30 PM

sorry.. i mean this is vb.net connectionstring not vb6...
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9055
  • View blog
  • Posts: 33,988
  • Joined: 12-June 08

Re: connection string app.path

Posted 09 May 2013 - 06:41 PM

http://connectionstr...com/access-2007

example:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;


You should be able to dynamically make that file path by appending something like

My.Computer.FileSystem.CurrentDirectory 

to your database name.
Was This Post Helpful? 0
  • +
  • -

#4 dave_mark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 15-March 13

Re: connection string app.path

Posted 09 May 2013 - 06:53 PM

this is from my vb6..
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Recruitment_DataBase.mdb"

i want it into vb.net. where i can access my database without specifying the whole path or address.. coz i want my .mdb to be place in the folder where my installer located..
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9055
  • View blog
  • Posts: 33,988
  • Joined: 12-June 08

Re: connection string app.path

Posted 09 May 2013 - 06:57 PM

yeah.. so if you get the current path of the executable you can tack on the db name and there's your path.
Was This Post Helpful? 0
  • +
  • -

#6 dave_mark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 15-March 13

Re: connection string app.path

Posted 09 May 2013 - 07:03 PM

but i want it to put it in my code so that i dont have to recode the connectionstring whenever ill transfer my folder... app.path works fine in vb6 but in vb.net doesnt...
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9055
  • View blog
  • Posts: 33,988
  • Joined: 12-June 08

Re: connection string app.path

Posted 09 May 2013 - 07:07 PM

Dude.. that's the whole point of the 'current directory' code I had in my first post. It pulls the directory you are currently operating in.. No need to hard code.. no need to specify anything - except for the f'n file name of your access db.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1