DB in a LAN -win200-system

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sakthivijai
    New Member
    • Aug 2006
    • 1

    DB in a LAN -win200-system

    Hai,
    How can I connect a MSAccess DB which is in same LAN on a Windows 2000 system using ADODB? Pl. Any one help me.
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi Sakti,

    use DSN connection.. kind follow the step below..

    1st step..
    place the db on any machine on lan.. share out the folder for public access with read & write permission set on..

    2nd step..
    create ODBC connection on client machine.. point the db path properties to the shared folder path location..

    3rd step.. the sample code segment..
    lest assume your ODBC connection is named (MyTestODBC).. ok..

    Requires project reference to Microsoft ActiveX Data Objects 2.x Library
    Code:
    Dim oConnection     As ADODB.Connection
    Dim oRecordset      As ADODB.Recordset
    Dim sMsg            As String
    Dim sConnectString  As String
    Dim sSQL            As String
     
    sConnectString = "DSN=MyTestODBC Data;OLE DB Services=-2;"
    sSQL = "SELECT Name FROM Employee"
    Set oConnection = New ADODB.Connection
    Set oRecordset = New ADODB.Recordset
     
    oConnection.Open sConnectString
    oRecordset.Open sSQL, oConnection, adOpenStatic, adLockOptimistic
    sMsg = "**********************" & Chr(10)
    Do While (Not oRecordset.EOF)
        sMsg = sMsg & oRecordset.Fields("Name") & Chr(10)
        oRecordset.MoveNext
    Loop
    sMsg = sMsg & "**********************" & Chr(10)
    MsgBox sMsg
     
    oRecordset.Close
    Set oRecordset = Nothing
    oConnection.Close
    Set oConnection = Nothing

    Comment

    Working...