Here is how I wrote the macro. Note that the getting and returning of ID part is not included here so as not to confuse reader.
sub updatedb()
Dim MyConn As ADODB.Connection
Dim MyRS As ADODB.Recordset
Set MyConn = New ADODB.Connection
MyConn.Open "DSN=odbcdsn;Uid=userid;Pwd=userpass"
SQL="insert int mytable (a,b) values ('" & ActiveSheet.Range("E1").Value & "','" & ActiveSheet.Range("F1").Value & "')"
Set MyRS = MyConn.Execute(Sql)
Set MyRS = Nothing
Set MyConn = Nothing
End Sub
No comments:
Post a Comment