4 Replies - 4809 Views - Last Post: 12 June 2010 - 01:13 AM Rate Topic: -----

#1 Ebisu  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 09-June 10

Setting a relative path for a database?

Posted 11 June 2010 - 10:00 PM

Hey i have so far set up a form to save data into a database and i am using:
 
 con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0.;" & _
    "Data Source = F:\Database1.mdb"
        con.Open()



I tried saving the database as i did with images in the resource folder and used my.resources but this didnt work is there any way i can save the database into the project folder and link to it no matter whan machine i am on?

Is This A Good Question/Topic? 0
  • +

Replies To: Setting a relative path for a database?

#2 janne_panne  Icon User is offline

  • WinRT Dev
  • member icon

Reputation: 428
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

Re: Setting a relative path for a database?

Posted 12 June 2010 - 12:28 AM

If your database is in your solution explorer, set it's copy local property to copy always and it will be copied to your application folder. If it's not in your solution explorer, add it there with Add existing item command and do the same.

And you can easily get your application's folder using Application.StartUpPath property.
Was This Post Helpful? 0
  • +
  • -

#3 Ebisu  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 09-June 10

Re: Setting a relative path for a database?

Posted 12 June 2010 - 12:46 AM

with copying always, wouldnt that make it overwrite the existing database deleting all my records each time?


The application thing seems to work though, thanks. i just put the DB in the folder manually, thinks it should work just as well?

This post has been edited by Ebisu: 12 June 2010 - 12:48 AM

Was This Post Helpful? 0
  • +
  • -

#4 janne_panne  Icon User is offline

  • WinRT Dev
  • member icon

Reputation: 428
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

Re: Setting a relative path for a database?

Posted 12 June 2010 - 12:55 AM

Yep, it should work too.

And yes, it would delete the records when you build the project again as the previous database would be replaced.
Was This Post Helpful? 0
  • +
  • -

#5 JITHU  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 62
  • View blog
  • Posts: 201
  • Joined: 02-July 07

Re: Setting a relative path for a database?

Posted 12 June 2010 - 01:13 AM

You can even set the Copy property to "Copy if newer". In this way, only if you make any changes to the db, it'll be copied to the app folder.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1