连接到DataBase ASP.NET时出现问题

时间:2010-06-22 23:55:07

标签: c# asp.net database vb.net oledb

我在同一工作区中有一个数据库,我尝试使用以下代码连接到此数据库:

Dim CX As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & "./Learning.mdb")

Dim CX As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & "~/Learning.mdb")

Dim CX As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & "~Learning.mdb")

但它们都不起作用。

1 个答案:

答案 0 :(得分:4)

尝试:

        Dim CX As OleDbConnection = New 
    OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &
 System.AppDomain.CurrentDomain.BaseDirectory & "/Learning.mdb")