locked
How would I define a relative path for an Access DB connection string ? RRS feed

  • Question

  • User756459238 posted

    I perform a lookup in an access database. The process works fine when on the local host, What can I do to make it work on the Web Server where the path is different and unknown at design time. I would like a releative path that would work on both? Is this possible? Below is the absolute path. Thanks for any help.

    Dim DBConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\WebSites\SFM\App_Data\vwd.mdb")

    DBConnection.Open()

     

     

    Saturday, August 4, 2007 4:21 PM

Answers

  • User-821857111 posted

    Dim DBConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|vwd.mdb")

    |DataDirectory| will find the App_Data Folder wherever your pages are actually deployed 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 4, 2007 5:26 PM

All replies

  • User-821857111 posted

    Dim DBConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|vwd.mdb")

    |DataDirectory| will find the App_Data Folder wherever your pages are actually deployed 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 4, 2007 5:26 PM
  • User756459238 posted

    Thank You

    Monday, August 6, 2007 6:00 PM
  • User2028412758 posted

    Dim DBConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|vwd.mdb")

    |DataDirectory| will find the App_Data Folder wherever your pages are actually deployed 

     

    I know you answered this a while ago, but I wanted to say thanks it really help with my issue of relative path for an access database in my Connection String

     cGRUS.com
     

    Friday, August 17, 2007 8:42 AM
  • User-821857111 posted
    I'm glad your search came up trumps.
    Friday, August 17, 2007 8:51 AM
  • User1115269075 posted

    I created tables in oracle in its default database.

    I wrote the connection string as following

    connectionString ="Provider=MSDAORA.1;UserID=scott;password=tiger;Host-String=local.world;database=ORA"

    I dont know the database name.

    How to find out the default database?

    Is it necessary to create a database? And if so then how we create a database and how we create tables in that database?

     

    Monday, January 14, 2008 11:45 AM
  • User714618360 posted

     Yeah, thanks a lot man!

    Saturday, February 28, 2009 6:43 PM