我有一个电子表格设置为通过 ADO 连接连接到 SQL Server。它的工作原理是,一旦在 Excel 中输入内容,就会打开与 SQL Server 的连接,然后我从 excel 文档中获取变量以输入到数据库中。这是我的代码:
SQLConnect = "Provider=sqloledb;Integrated Security=SSPI;" & _
"Data Source=NCCHAR9\PDS_SSQL; Database=MWPMO; " & _
"Persist Security Info=False;"
Conn1.ConnectionString = SQLConnect
Conn1.CursorLocation = adUseClient
Conn1.Mode = adModeReadWrite
Conn1.Open
Cmd1.ActiveConnection = Conn1
Cmd1.CommandText = "UPDATE Input_Tracker SET " & varCol & " = NULL WHERE [ID] = " & varKey & ""
Cmd1.Execute
Cmd1.CommandText = "INSERT INTO Input_Changes(ID, TableName, ColumnName, OldData, NewData, UserID, DateTime) " _
& "VALUES('" & varKey & "','" & tblnm & "','" & varCol & "','" & Oval1 & "','" & varData & "','" & username & "','" & Now() & "')"
Cmd1.ExecuteConn1.Close
Set Conn1 = Nothing
我的问题是,这段代码以某种方式锁定了 SQL Server 中的表,使其不时更新。我不是数据库的管理员,但我确实让他们看了一下,他们找不到任何人锁定表。创建此间歇性问题的代码是否有问题?我能做些什么?