Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need ODBC equivalent please....

Status
Not open for further replies.

Yogi39

Technical User
Jun 20, 2001
273
CA
I use the following code from a an Excel Worksheet Macro(client Side) to connect and update the Spreedsheet and Database(also Client side)
Now I need to convert the connection to an ODBC connection to connect to an Access 2000 databse on the web(serverside)
from my client side Excel Spreedsheet wich is still gonna remain on the clent side....
Can anyone help me please ?

Code:
Sub syncroc()

Dim max_row As Integer
Dim row As Integer
Dim col As Integer
Dim CON As ADODB.Connection
Dim sync() As String
Dim new_value As String
Set CON = New Connection
CON.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=E:\~QA\New Folder (12)\Wow.mdb"

max_row = Sheets("Mydata").UsedRange.Rows.Count
For row = 2 To max_row
        ID = ActiveSheet.Cells(row, 1).Value
        Name = ActiveSheet.Cells(row, 2).Value
        Age = ActiveSheet.Cells(row, 3).Value
        Salary = ActiveSheet.Cells(row, 4).Value
        
        Dim rs As New Recordset
    rs.Open "Select * from Master where ID=" & ID, CON, adOpenKeyset, adLockOptimistic
    If rs.RecordCount <> 0 Then
        rs![ID] = ID
        rs![Name] = Name
        rs![Age] = Age
        rs![Salary] = Salary
        rs.Update
        rs.Close
     Else
        If rs.RecordCount = 0 Then
            rs.AddNew
            rs![ID] = ID
            rs![Name] = Name
            rs![Age] = Age
            rs![Salary] = Salary
            rs.Update
            rs.Close
        End If
     End If
     Next row

    CON.Close
    Set CON = Nothing
   
End Sub
 
There's not much to do in the code. You just go to the ODBC icon in you control panel and set up an MS ACCESS data source. The you replace your con.open statement with

con.open &quot;dsn=whatever_you_name_your_datasource&quot;

But if you can see your web server as a drive you can just change the path in the code you have.
 
Not quite sure that I can this way.
I would have to build the whole string.

I would need to know how to get an ODBC connection from my computer to an Access MDB on a web server which is hosting the Database.
Can anyone help me ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top