Relative Pathnames in a WebForm

Thoth

Active member
Joined
Jun 27, 2003
Messages
26
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 dont 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 Im not quite sure where the application "resides", per se, so maybe Im thinking its in a directory when its actually not.
 
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)
 
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 its executing from the WINNT\System32 directory.

I need to have something that can be set at runtime in the Connection String.
 
Alright, I see what you mean. However, Im 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.
 
Im 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?
 
Back
Top