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
Printable View
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
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".
Will it work even if i transfer my database and application in any folder??
How am i going to use the App.pAth version of VB.net in this connection stringCode:con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\TimeKeepingDB.accdb;Jet OLEDB:Database Password=tim3keeping23"
[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: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.Code:con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\TimeKeepingDB.accdb;Jet OLEDB:Database Password=*************"
Thanks for providing your database password too, by the way.
Never happened to me or anyone that I know.Quote:
Originally Posted by M$Arrogance
How well do you need it documented?Quote:
Originally Posted by M$Arrogance
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
Sorry for what happened in your thread bizzy_e23 but we've taken care of it.
wierd he responded like that with his first post. Did you do a ip-check?