I assume from your post that you have some subsolder that contains the admin part of your application.
What's happening here is that the IIS root lives here:
c:\Inetpub\wwwroot (
http://localhost/)
And your application lives here:
c:\shailesh (
http://localhost/shailesh)
while the data file lives here:
c:\shailesh\data\data.mdb (
http://localhost/shailesh/data/data.mdb)
In your admin part the data file is referenced like this:
http://localhost/shailesh/admin/../data/data.mdb
Which returns
c:\shailesh\data\data.mdb
But your client part at the application root tries this:
http://localhost/shailesh/../data/data.mdb
Which is returning
c:\Inetpub\wwwroot\data\data.mdb
You need to change your location relative virtual path in the call to MapPath to a root relative path so that you can always reference the data file off the application root regardless of where the calls are being made.
To solve this problem for any folder/page location, change the data file path to a root relative virtual path with the ~ character as substitute for your application root. The Server.MapPath method will replace it with the full application root path and make it relative to the SERVER root (i.e. any path that starts with "/"). This will make the reference work from any location in your application.
For example:
strConn= "Provider=Microsoft.Jet.OLEDB.4.0;data source=";
strConn+= System.Web.HttpContext.Current.Server.MapPath("~/data/data.mdb") + ";";
-
Peter