I currently have my ADO connection set up as such:
Dim rs As New ADODB.Recordset
Dim sqlStat As String
Dim adoConn As New ADODB.Connection
Dim adoCmd As New ADODB.Command
Dim strConn As String, strSQL as String
'Open a Connection object
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
strConn = strConn & "c:\myMDB.mdb"
adoConn.ConnectionString = strConn
adoConn.Open
sqlStat = "SELECT * FROM Table"
rs.Open sqlStat, CurrentProject.Connection
strSQL = "INSERT INTO NEWTABLE VALUES (value1, value2)"
' Set up the Command object
adoCmd.CommandText = strSQL
adoCmd.CommandType = adCmdText
adoCmd.ActiveConnection = adoConn
Do until rs.eof
value1 = rs("FIELD1")
value2 = rs("FIELD2")
adoCmd.Execute
loop
rs.close
set rs=nothing
Set adoCmd = Nothing
adoConn.Close
Set adoConn = Nothing
My question is, can anyone simplify the ado connection? It seems kind of redundant.
thanks!
ft
Set the gearshift for the high gear of your soul, you've got to run like an antelope, out of control.
Dim rs As New ADODB.Recordset
Dim sqlStat As String
Dim adoConn As New ADODB.Connection
Dim adoCmd As New ADODB.Command
Dim strConn As String, strSQL as String
'Open a Connection object
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
strConn = strConn & "c:\myMDB.mdb"
adoConn.ConnectionString = strConn
adoConn.Open
sqlStat = "SELECT * FROM Table"
rs.Open sqlStat, CurrentProject.Connection
strSQL = "INSERT INTO NEWTABLE VALUES (value1, value2)"
' Set up the Command object
adoCmd.CommandText = strSQL
adoCmd.CommandType = adCmdText
adoCmd.ActiveConnection = adoConn
Do until rs.eof
value1 = rs("FIELD1")
value2 = rs("FIELD2")
adoCmd.Execute
loop
rs.close
set rs=nothing
Set adoCmd = Nothing
adoConn.Close
Set adoConn = Nothing
My question is, can anyone simplify the ado connection? It seems kind of redundant.
thanks!
ft
Set the gearshift for the high gear of your soul, you've got to run like an antelope, out of control.