0
Iam嘗試通過Excel更新sql中的記錄。我已經在excel中的按鈕上寫下了一些代碼,以在sql server中插入和更新記錄。我設法插入記錄,但在更新查詢時出錯。我已經在stackoverflow上檢查瞭解決方案,但仍然出現錯誤。任何人都可以檢查什麼亞姆做錯了在下面的代碼行使用VBA更新查詢
conn.Execute = "UPDATE dbo.EmployeeInfo" _
& "SET Week= ('" & Week& "') " _
& "Time= ('" & Time & "') " _
& "DateFrom = ('" & DateFrom & "') " _
& "DatoTo = ('" & DatoTo & "') " _
& "Name= ('" & Name & "') " _
& "Description= ('" & Description & "') " _
& "Codes= ('" & Codes& "')" _
& "WHERE Week= (" & .Cells(iLoop, 1) & ")
AND DateFrom = (" & .Cells(iLoop, 3) & ")
AND DatoTo = (" & .Cells(iLoop, 4) & ")
AND Name= (" & .Cells(9, oLoop) & ")"
你需要每個「列=價值」,即集之間的逗號c1 = 1,c2 = ... – jarlh
之前_ u表示 – meer
不知道VBA,所以我不能說。我知道SQL。 「更新表名集col = val,col = val,col = val」 – jarlh