
Originally Posted by
RhinoBull
Many people are asking if it is possible to connect to remote MS Access database. Well, I can say it is possible but a bit tricky - you must have IIS running on the server, plus some configs for ado library on the server are also in order.
Here is the general idea on coding:
VB Code:
Option Explicit
Dim adoConn As ADODB.Connection
Dim adoRst As ADODB.Recordset
Private Sub Command1_Click()
'============================
Dim strConString As String
Dim strSQL As String
'assign connection string
strConString = "Provider=MS Remote;" & _
"Remote Server=http://192.168.1.1;" & _
"Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=MyRemoteDB;Persist Security Info=False"
'initialize connection object variable
Set adoConn = New ADODB.Connection
'open connection
adoConn.Open strConString, "admin", ""
strSQL = "Select * from Orders"
'initialize recordset object variable
Set adoRst = New ADODB.Recordset
With adoRst
.Open strSQL, adoConn, , , adCmdText
If Not .EOF Then
Do While Not .EOF
'read each record here
'...
.MoveNext
Loop
.Close
End If
End With
'destroy recordset object if necessary (or do it when you unload the form)
'Set adoRst = Nothing
'destroy connection object if necessary (or do it when you unload the form)
'Set adoConn = Nothing
End Sub
For information on how to cofigure IIS refer to the following MSDN article:
http://support.microsoft.com/kb/q253580/
I hope this sample is going to be usefull.
Hi friend...
I have an IIS server installed and run correctly (i us asp page to connet the and mdb) but interesting to connect on this server via VB 6.0.
Question:
1) where is the dir to copy the mdb? (...\\inetpub\wwwroot\test.mdb)
2) you have insert in ope rset "admin" wath is refred this psword?
Note:
with your example uin other case have error run time 8447 and use i this code:
Code:
Option Explicit
Dim adoConn As ADODB.Connection
Dim adoRst As ADODB.Recordset
Private Sub Command1_Click()
'============================
Dim strConString As String
Dim strSQL As String
'assign connection string
strConString = "Provider=MS Remote;" & _
"Remote Server=http://10.220.238.25;" & _
"Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=DUE.mdb;Persist Security Info=False"
'initialize connection object variable
Set adoConn = New ADODB.Connection
'open connection
adoConn.Open strConString, "sal", ""
strSQL = "Select * from scheda"
'initialize recordset object variable
Set adoRst = New ADODB.Recordset
With adoRst
.Open strSQL, adoConn, , , adCmdText
If Not .EOF Then
Do While Not .EOF
'read each record here
'...
.MoveNext
Loop
.Close
End If
End With
'destroy recordset object if necessary (or do it when you unload the form)
'Set adoRst = Nothing
'destroy connection object if necessary (or do it when you unload the form)
'Set adoConn = Nothing
End Sub