Visual Studio 2005 -- When using and Access Database, VS prompts you to add it, automatically puts it in the App_data folder, and then creates a connection string. As always having used this configuration, I'm unsure how to modify the connection string in the Web.Config file when I move it to my _database folder in my Website project. How do I modify |Data Directory|?
Can you give us an example of the connection string it creates. It looks like you simply need to update the path of the connection string. rcp DiscountASP.NET www.DiscountASP.NET
Currently the connection string looks like this when it's in the App_Code folder which is in the root of my app <add name="CG_2" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;|DataDirectory|\MyDatabase.mdb&quot;" providerName="System.Data.OleDb" /> So, if I add _Database folder to the same level that the App_Code folder is in.... i.e. Rename the App_Code folder to _Database... how do I update the above connection string?
Huh? No clue what you're talking about. Am I at DiscountASP.net? The site that has 2.0 -3.5 .NET Framework that I paid for? I don't write any ASP pages anymore. That's old.I'm trying to write ASPX pages. I read about this: AppDomain.CurrentDomain.SetData("DataDirectory", newpath) But I don't know where to place it -- in my connection string declaration? or in the Web.config?
I'm doing my best to help ya. Yes we're ASP.NET coders here but that asp code I pasted is just a quick old school method to retrieve qualified paths. What is the Starter Kit you're using Access with?
Dim strConnection?? The Web.config is an XML file so it needs to follow this format: <add name="CG_Cnn" connectionString="provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;= + Server.MapPath("../_database/MyDatabase.mdb)&quot; "providerName="System.Data.OleDb" /> Please type every nuance, it needs to be accurate. I tried it, but it doesn't work -- If I attempt to look at a DataSet... I receive this: Following error occured while getting connection string information from configuration. "Object reference not set to an instance of an object."
I don't like making Access connections in the web.config that's why I recommend the code page. You can't MapPath inside the web.config settings but you can use the full path. To get the full path on your server create an ASP page, path.asp or whatever, with this code: