Access connection string problem

Discussion in 'ASP.NET / ASP.NET Core' started by CaptainZ, Mar 4, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I?m trying to run my discountasp web app for the first time.</o:p>
    </o:p>
    I have a connection string to my Access database as follows?</o:p>
    </o:p>
    Public JetConnString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" &amp; _</o:p>
    "Data Source = " &amp; HttpContext.Current.Server.MapPath("\SAMPrebook\_database\SAMPrebook.mdb")</o:p>
    </o:p>
    SAMPrebook is my virtual folder.

    When my aspx page attempts to open the database, I get the following error?</o:p>
    </o:p>
    'E:\web\cepmgiftcom\htdocs\SAMPrebook\_database\SAMPrebook.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.

    The connection string works fine on my local host.

    </o:p>I have also tried...

    Public JetConnString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" &amp; _</o:p>
    "Data Source = " &amp; HttpContext.Current.Server.MapPath("_database\SAMPrebook.mdb")</o:p>

    and...

    Public JetConnString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" &amp; _</o:p>
    "Data Source = " &amp; HttpContext.Current.Server.MapPath("SAMPrebook.mdb")</o:p>

    In all cases, I get anerror that refers to ''E:\web\cepmgiftcom\htdocs'</o:p>
    </o:p>
    Could someone please tell me what I?m doing wrong? </o:p>
    </o:p>
    Thanks very much</o:p>
     
  2. Try:
    Public JetConnString As String = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;' & _ 'Data Source = ' & HttpContext.Current.Server.MapPath('_database\\SAMPrebook.mdb') <---('\\' instead of '\')

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. It worked!

    Thank you very, very much.
     
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