l--*_*''' 2 mysql sql excel odbc vba
我正在使用odbc通过excel连接到mysql数据库
这条线做什么?
Set rs = oConn.Execute("SELECT @@identity", , adCmdText)
Run Code Online (Sandbox Code Playgroud)
我无法更新数据库:
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("datapath") = dpath
.Fields("analysistime") = atime
.Fields("reporttime") = rtime
.Fields("lastcalib") = lcalib
.Fields("analystname") = aname
.Fields("reportname") = rname
.Fields("batchstate") = "bstate"
.Fields("instrument") = "NA"
.Update ' stores the new record
End With
Run Code Online (Sandbox Code Playgroud)
它只是更新.Fields("instrument")="NA",但是对于所有其他字段,它都是NULL值
它选择(并返回)插入当前连接中IDENTITY COLUMN的最后一个值.
以下是该主题的参考资料
http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html