How to set the database path to the current folder  
Author Message
Agent00





PostPosted: ASMX Web Services and XML Serialization, How to set the database path to the current folder Top

Hi,

I'm working with Visual Web Development with Visual C# Express

I have a project folder that I work with in My Document->TestASPNet and I put my Northwind.mbd in that folder (TestASPNet) and set my C# code as below. But somehow Visual Web Development give me an error. Then I put my Northwind.mdb in this folder (C:\Program Files\Microsoft Visual Studio 8\Common7\IDE) then it works. Please, help me to set the path, so I can put it in my current working directory, which is My Document->TestASPNet.

string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=.\\Northwind.mdb";

P.S If I load it to my website, what path do I use

Thanks

Jason




.NET Development30  
 
 
tangfx





PostPosted: ASMX Web Services and XML Serialization, How to set the database path to the current folder Top

hello, I guess that your directory is created in visual studio 2005, asp.net can't access you mdb because this directory is used for readonly . you should create a asp.net directory named App_Data in visual studio solution resource manager, and move database in it;

then in aspx, write code for connection such as:

string connectString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("~/App_Data/Northwind.mdb");


 
 
Agent00





PostPosted: ASMX Web Services and XML Serialization, How to set the database path to the current folder Top

Hi Tangfx,

Thanks for the reply and thanks for your help. I got it to work. I'm using Visual Web Depeloper 2005 and I'm new to ASP.NET, so I'm still learning and thanks to your help which make my learning much easier and more pleasant with ASP.net.

Thanks

Jason