[VB .Net 2010] Coding Help

Discussion in 'Mixed Languages' started by Chronic, Sep 12, 2011.

  1. Chronic

    Chronic MDL Novice

    Sep 12, 2011
    2
    0
    0
    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;")
     
  2. Chronic

    Chronic MDL Novice

    Sep 12, 2011
    2
    0
    0
    can anybody help me with this please I really need some help
     
  3. BobSheep

    BobSheep MDL Guru

    Apr 19, 2010
    2,326
    1,358
    90
    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;")
     
  4. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,873
    20,137
    180
    #4 Alphawaves, Sep 13, 2011
    Last edited by a moderator: Apr 20, 2017
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. SiRaDuDe

    SiRaDuDe MDL Novice

    Oct 4, 2011
    9
    1
    0
    #5 SiRaDuDe, Oct 4, 2011
    Last edited by a moderator: Apr 20, 2017
    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 :tongue2:
     
  6. stevengrilles

    stevengrilles MDL Novice

    Feb 21, 2012
    3
    0
    0
    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.