Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

I have a simple code that i want to convert it from a Virtual Path to Phisical Path:

 

Sub Page_Load (Source As Object, E as EventArgs)

Dim strConn as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("guestbook.mdb") & ";"

Dim MySQL as string = "SELECT Name, EMail, URL, Comment FROM Guestbook"

Dim MyConn as New OleDBConnection (strConn)

Dim Cmd as New OleDBCommand (MySQL, MyConn)

MyConn.Open ()

rptGuestbook.DataSource = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

rptGuestbook.DataBind()

End Sub

 

Can someone help me?

Thank's.

Posted

Server.MapPath() should work for you...but if your database isn't in the root folder of your project you'd need to supply a full virtual path for it to get it properly "mapped", for ex:

 

Dim sDbPath As String = Server.MapPath("/yourappfolder/yourdatafolder/yourdatabase.mdb")

 

Paul

Posted (edited)

It's Request.PhysicalApplicationPath

 

I personally don't use Server.MapPath but it does exist, can be used, and was the context of the original question.

 

If you're giving a relative virtual path that leads off with a slash it's relative to your virtual root. There's little question about how that path will be interpreted.

 

I would agree that relative pathing in general can sometimes cause problems.

 

Paul

Edited by PWNettle

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...