Results 1 to 8 of 8

Thread: server.Mappath

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    6

    server.Mappath

    Say i have something like this:

    VB Code:
    1. <connectionStrings>
    2.         <add name="DBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Inetpub\wwwroot\Prima\App_Data\DB.mdb"; providerName="System.Data.OleDb" />
    3. </connectionStrings>
    but i want to make it with relative path like this


    VB Code:
    1. <connectionStrings>
    2.         <add name="DBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=~\App_Data\DB.mdb"; providerName="System.Data.OleDb" />
    3. </connectionStrings>

    but when i replace the path with the tilda '~' i get an error (exception) "'C:\WINDOWS\system32\~\App_Data\DB.mdb' is not a valid path...."

    Thanks for the help

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: server.Mappath

    VB Code:
    1. "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.MapPath("\Prima\App_Data\DB.mdb") & "; providerName=System.Data.OleDb"

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    6

    Re: server.Mappath

    Well now i am getting warning msg from intellisense:

    Missing attribute value on attribute 'server.MapPath'


    VB Code:
    1. <add name="DBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source==" & server.MapPath("\Prima\App_Data\DB.mdb") & "; providerName="System.Data.OleDb" />

    Tnx

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    6

    Re: server.Mappath

    Btw, i am using VB 2005 and web.config for the purpose (if it helps at all)

  5. #5
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: server.Mappath

    Sorry I goofed that up a little, use your original config settings, then do a replace on the tilde with the information I gave you.

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    6

    Re: server.Mappath

    And how finally it suppose to look like? I had a couple tries but none of them wasn't succefull. Thanks in advance

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    6

    Re: server.Mappath

    *bump*

  8. #8

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    6

    Re: server.Mappath

    Nobody knows that? hah ... lol
    Whatever ... thanks for reading it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width