Dim con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\data.mdb;") I need help with this line of code, it loads the database file from a local directory I've uploaded the database file to my website, and I have tried many different ways to get it to connect to the online database but I keep getting errors could anybody help me with this please and thanks alot This is the code I tried and a few other ways but I havent had any luck Dim con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=SITE LINK HERE/data.mdb;")
What's in |DataDirectory| and SITE LINK HERE. This needs to be either a fully qualified path or a relative path to the file. I.e Data Source=.\Data\data.mdb; Data Source=..\Data\data.mdb; or Data Source=e:\Data\data.mdb;")
An example here: Code: Imports System.Data.OleDb Dim connetionString As String Dim cnn As OleDbConnection connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdatabasename.mdb;" cnn = New OleDbConnection(connetionString) Try cnn.Open() MsgBox("Connection Open ! ") cnn.Close() Catch ex As Exception MsgBox("Can not open connection ! ") End Try http://vb.net-informations.com/ado.net-dataproviders/ado.net-oledbconnection.htm
Just for Info... Some Hosting services like Godaddy will not allow the placement of an access.mdb just anywhere, they supply a specific folder for it, allow one a few, and you must access it by using a FDN... Wait... what I'm I saying... I think Godaddy actually did away with accessing an Access .MDB all together on all their 4GH hostings, IIRC Copied from godaddy hosting: (very old method) Connecting to an Access Database Using ASP/ADO NOTE: This code requires full trust and will NOT work on hosting accounts running ASP.Net 2.0/3.0/3.5/4.0. Code: <% Dim oConn, oRs Dim qry, connectstr Dim db_path Dim db_dir db_dir = Server.MapPath("access_db") & "\" db_path = db_dir & "yourdatabasefile.mdb" fieldname = "your_field" tablename = "your_table" connectstr = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & db_path Set oConn = Server.CreateObject("ADODB.Connection") oConn.Open connectstr qry = "SELECT * FROM " & tablename Set oRS = oConn.Execute(qry) if not oRS.EOF then while not oRS.EOF response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "" oRS.movenext wend oRS.close end if Set oRs = nothing Set oConn = nothing %> Godaddy
VB.Net is one of the greatest programing language. It supports to many drag and dro tools which make your designing and coding much simpler and easier, so that could be more beneficial to you.