Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Still getting my head around this ADO stuff... sigh.
  • *Experts*
Posted

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)

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

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.

Still getting my head around this ADO stuff... sigh.
  • *Experts*
Posted
The property I mentioned does that exactly.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

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.

Still getting my head around this ADO stuff... sigh.
Posted

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?

Still getting my head around this ADO stuff... sigh.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...