在显示此错误之前,此代码可能连续运行5次。它是Excel表单中一个按钮的一部分,该按钮将数据放入SQL数据库。
'Delete the previous linked doc if it exists. Match up with quote number.
If fileType = ".xlsb" Then
con.Execute "delete from CONTSUPP where LINKEDDOC like '%" & Sheets("Quote Sheet").Range("G7").Value & "%' AND LINKEDDOC like '%" & Sheets("Quote Sheet").Range("B11").Value & "%.xlsb%' "
ElseIf fileType = ".pdf" Then
con.Execute "delete from CONTSUPP where LINKEDDOC like '%" & Sheets("Quote Sheet").Range("G7").Value & "%' AND LINKEDDOC like '%" & Sheets("Quote Sheet").Range("B11").Value & "%.pdf%' "
End If
rs.Open "select LINKEDDOC from CONTSUPP where LINKEDDOC like '%" & savePath & "%' "
If rs.EOF Then
'Open database connection
rs.Close
Sql = "" & _
"declare @gmnv varchar(20), @recid varchar(15) " & _
"set nocount OFF " & _
"EXEC Castell_Create @gmnv OUTPUT " & _
"EXEC Castell_SetValue @gmnv, 'accountno', '" & Sheets("Quote Sheet").Range("N22").Value & "' " & _
"EXEC Castell_SetValue @gmnv, 'filename', '" & savePath & "' " & _
"EXEC Castell_SetValue @gmnv, 'user', 'MASTER' " & _
"EXEC Castell_SetValue @gmnv, 'notes', '' " & _
"EXEC Castell_SetValue @gmnv, 'ref', '" & Sheets("Quote Sheet").Range("G7").Value & "-" & Sheets("Quote Sheet").Range("B11").Value & "' " & _
"EXEC Castell_WriteLinkedDoc @gmnv " & _
"EXEC dbo.Castell_Delete @gmnv"
con.Execute Sql
Else
'MsgBox "Link found!"
Exit Function
End If
这是一个示例,其中生成此消息的实际数据的格式看上去更好。
declare @gmnv varchar(20), @recid varchar(15) set nocount OFF
EXEC Castell_Create @gmnv OUTPUT
EXEC Castell_SetValue @gmnv, 'accountno', 'A3081527308)*83QWAmo'
EXEC Castell_SetValue @gmnv, 'filename', '\\acs03\gmapp\Quotes\Bill_Fegley\Deer_Ridge_Construction\bf19-191_Wise\bf19-191_Wise_BLD_QUO_Construction.pdf'
EXEC Castell_SetValue @gmnv, 'user', 'MASTER'
EXEC Castell_SetValue @gmnv, 'notes', ''
EXEC Castell_SetValue @gmnv, 'ref', 'bf19-191-Wise'
EXEC Castell_WriteLinkedDoc @gmnv
EXEC dbo.Castell_Delete @gmnv