-
Jun 22nd, 2008, 08:03 PM
#1
Thread Starter
Lively Member
[2008] "App.Path" in VB.net
Hi guys,
I want my database path to be flexible, Im using App.Path in my code in VB6, how about in VB.net
Thanks
-
Jun 22nd, 2008, 08:23 PM
#2
Re: [2008] "App.Path" in VB.net
In your connection string you use |DataDirectory| for the folder, which will then be resolved to the appropriate location at run time. Note that you do NOT do this in code. It's part of the connection string, which you can create at design time or at run time. For instance, if you're using SQL Server Express your connection string may include "AttachDbFileName=|DataDirectory|\MyDatabase.mdf".
-
Jun 22nd, 2008, 08:33 PM
#3
Thread Starter
Lively Member
Re: [2008] "App.Path" in VB.net
Will it work even if i transfer my database and application in any folder??
-
Jun 22nd, 2008, 08:38 PM
#4
Thread Starter
Lively Member
Re: [2008] "App.Path" in VB.net
Code:
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\TimeKeepingDB.accdb;Jet OLEDB:Database Password=tim3keeping23"
How am i going to use the App.pAth version of VB.net in this connection string
-
Jun 22nd, 2008, 08:43 PM
#5
Re: [2008] "App.Path" in VB.net
[Edited by MartinLiss] I already answered your question. I said use |DataDirectory| for the folder and to not do it in code because it's part of your connection string. I even provided an example. How is that not clear? Let me spell it out for you:
Code:
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\TimeKeepingDB.accdb;Jet OLEDB:Database Password=*************"
As you seem to be having a little trouble the first time around, let me also say again that that will be resolved to the appropriate folder at run time.
Thanks for providing your database password too, by the way.
Last edited by MartinLiss; Dec 19th, 2008 at 01:27 PM.
-
Dec 18th, 2008, 06:53 PM
#6
Re: [2008] "App.Path" in VB.net
Originally Posted by M$Arrogance
Well tell me why the vs ide loses the path to the database when you use it?
Never happened to me or anyone that I know.
Originally Posted by M$Arrogance
Why do ... M$ not have it documented any better than it is?
How well do you need it documented?
http://msdn.microsoft.com/en-us/library/ms254500.aspx
http://www.connectionstrings.com/access
http://www.connectionstrings.com/access-2007
http://www.connectionstrings.com/sql-server-2005
-
Dec 19th, 2008, 01:30 PM
#7
Re: [2008] "App.Path" in VB.net
Sorry for what happened in your thread bizzy_e23 but we've taken care of it.
-
Dec 19th, 2008, 03:30 PM
#8
Addicted Member
Re: [2008] "App.Path" in VB.net
wierd he responded like that with his first post. Did you do a ip-check?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|