The goal is to overwrite a particular table in my Access 2000 db with the values from the collected recordset. I have collected the record set with success, however I am stumped at this point on how to get the recordset into my table.
The new table name can be anything, however for the sake of clarity, for now the table name is tblResults. The fields are exactly the same in the SQL db.
The reasons why I am not linking the tables is that this db exists in a high security Novell managed LAN, trusted connections (DSN, ODBC) are not allowed, my SQL Admin has given me one login, and there will be multiple users with there own local copy (no replication necessary, data is temporary). Hence, the connection string and the gathering of the data resolves my security problems.
The do loop is just to check to see if I collected the correct records.
Can anyone add the code to solve my problem?
The following is the code under the button on a form in an Access 2000 DB.
Private Sub Command4_Click()
On Error GoTo Err_Command4_Click
Dim cnnDiv As New ADODB.Connection
Dim rsDiv As New ADODB.Recordset
Dim objCom As New ADODB.Command
Dim iniRecCount As Integer
cnnDiv.Open "Driver={SQL Server};" & _
"Server=svrname;" & _
"Database=dbasename;" & _
"Uid=xxxxx;" & _
"Pwd=xxxxxx"
objCom.CommandType = adCmdStoredProc
objCom.ActiveConnection = cnnDiv
objCom.CommandText = "proDiv2"
Set rsDiv = objCom.Execute
iniRecCount = rsDiv.RecordCount
Do Until rsDiv.EOF = True
MsgBox rsDiv("RcNum").Value
rsDiv.MoveNext
Loop
cnnDiv.Close
Set cnnDiv = Nothing
Set rsDiv = Nothing
Exit_Command4_Click:
Exit Sub
Err_Command4_Click:
MsgBox Err.Description
Resume Exit_Command4_Click
End Sub
The new table name can be anything, however for the sake of clarity, for now the table name is tblResults. The fields are exactly the same in the SQL db.
The reasons why I am not linking the tables is that this db exists in a high security Novell managed LAN, trusted connections (DSN, ODBC) are not allowed, my SQL Admin has given me one login, and there will be multiple users with there own local copy (no replication necessary, data is temporary). Hence, the connection string and the gathering of the data resolves my security problems.
The do loop is just to check to see if I collected the correct records.
Can anyone add the code to solve my problem?
The following is the code under the button on a form in an Access 2000 DB.
Private Sub Command4_Click()
On Error GoTo Err_Command4_Click
Dim cnnDiv As New ADODB.Connection
Dim rsDiv As New ADODB.Recordset
Dim objCom As New ADODB.Command
Dim iniRecCount As Integer
cnnDiv.Open "Driver={SQL Server};" & _
"Server=svrname;" & _
"Database=dbasename;" & _
"Uid=xxxxx;" & _
"Pwd=xxxxxx"
objCom.CommandType = adCmdStoredProc
objCom.ActiveConnection = cnnDiv
objCom.CommandText = "proDiv2"
Set rsDiv = objCom.Execute
iniRecCount = rsDiv.RecordCount
Do Until rsDiv.EOF = True
MsgBox rsDiv("RcNum").Value
rsDiv.MoveNext
Loop
cnnDiv.Close
Set cnnDiv = Nothing
Set rsDiv = Nothing
Exit_Command4_Click:
Exit Sub
Err_Command4_Click:
MsgBox Err.Description
Resume Exit_Command4_Click
End Sub