Path to Access database in codefiles

Discussion in 'Databases' started by tinker, Apr 15, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I need to read (read-only) an Access database where the name of database will change depending on the current date. On my workstation, I set the connection string in the code file like:

    string strFilePath = "E:\\databases\\" + DateTime.Now.ToString("MMyy") + ".mdb";

    And use it first as:

    FileInfo objTestFile = new FileInfo(strFilePath);
    litUpdated.Text = string.Format("{0:h:mm tt on MMMM d, yyyy}", objTestFile.LastWriteTime);


    I've been playing with this all day to use the "_database" folder, and cannot seem to get it right.

    Help, please?

    (I'm not locked in to doing this is the code file, but if there's a way to combine a <connenctionString> with a variable file name, I haven't found it..)

    - Tinker
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    use server.mappath function.

    eg.

    string strFilePath = server.MapPath("_database") + DateTime.Now.ToString("MMyy") + ".mdb";
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page