473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.
Aug 20 '06 #1
1 962
sashi
1,754 Expert 1GB
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
Expand|Select|Wrap|Line Numbers
  1. Dim oConnection     As ADODB.Connection
  2. Dim oRecordset      As ADODB.Recordset
  3. Dim sMsg            As String
  4. Dim sConnectString  As String
  5. Dim sSQL            As String
  6.  
  7. sConnectString = "DSN=MyTestODBC Data;OLE DB Services=-2;"
  8. sSQL = "SELECT Name FROM Employee"
  9. Set oConnection = New ADODB.Connection
  10. Set oRecordset = New ADODB.Recordset
  11.  
  12. oConnection.Open sConnectString
  13. oRecordset.Open sSQL, oConnection, adOpenStatic, adLockOptimistic
  14. sMsg = "**********************" & Chr(10)
  15. Do While (Not oRecordset.EOF)
  16.     sMsg = sMsg & oRecordset.Fields("Name") & Chr(10)
  17.     oRecordset.MoveNext
  18. Loop
  19. sMsg = sMsg & "**********************" & Chr(10)
  20. MsgBox sMsg
  21.  
  22. oRecordset.Close
  23. Set oRecordset = Nothing
  24. oConnection.Close
  25. Set oConnection = Nothing
  26.  
Aug 20 '06 #2

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.