Thoth Posted August 8, 2003 Posted August 8, 2003 I want to use a relative path to open a database, however, I am doing this from a webform. I put the database in the same directory as the webform, but when I try to make the connection, I get this error: Could not find file 'C:\WINNT\system32\CBSWeb.mdb'. I don't think that putting the database in that directory is the proper solution, so can anyone help? Is it even possible to do relative paths with webforms? I think the issue is that I'm not quite sure where the application "resides", per se, so maybe I'm thinking it's in a directory when it's actually not. Quote Still getting my head around this ADO stuff... sigh.
*Experts* Bucky Posted August 8, 2003 *Experts* Posted August 8, 2003 The application resides, by default, in c:\inetpub\wwwroot\appname\, although this could be different. To get the local application path, you can use the PhysicalApplicationPath property of the HttpRequest class (accessible from any ASPX page by Request.PhysicalApplicationPath) Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Thoth Posted August 8, 2003 Author Posted August 8, 2003 I did that, however, I also did this: Dim strExe as String = System.Reflection.Assembly.GetExecutingAssembly.Location.ToString Dim d As System.IO.FileInfo d = New System.IO.FileInfo(strExe) By doing this, I determined that it's executing from the WINNT\System32 directory. I need to have something that can be set at runtime in the Connection String. Quote Still getting my head around this ADO stuff... sigh.
*Experts* Bucky Posted August 8, 2003 *Experts* Posted August 8, 2003 The property I mentioned does that exactly. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Thoth Posted August 8, 2003 Author Posted August 8, 2003 Alright, I see what you mean. However, I'm having a lot of trouble inserting a String object into the Connection String; it seems like the object is being completely ignored. I want to be able to dynamically set the pathname of the Connection String. Quote Still getting my head around this ADO stuff... sigh.
Thoth Posted August 12, 2003 Author Posted August 12, 2003 I'm still getting the same issue... in my wwwroot\appname folder, I have a folder named Database, and inside it I have a file, CBSWeb.mdb. So, because I want to use relative pathnames, I set this for my connection string: Me.objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=Database\CBSWeb.mdb;" When I try to run the program, I get this error: 'C:\WINNT\system32\Database\CBSWeb.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. So it somehow thinks I am running from the system32 directory. Is there any way around this so I can use a relative path name? Quote Still getting my head around this ADO stuff... sigh.
Thoth Posted August 12, 2003 Author Posted August 12, 2003 Problem solved, ignore this thread. Quote Still getting my head around this ADO stuff... sigh.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.