Search code examples
c#asp.netdatabasevb.netoledb

Problem while connecting to DataBase ASP.NET


I have a database in the same workspace, I've tried to connect to this DB using this codes :

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")

But none of them work.


Solution

  • Try:

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