我有以下SQL查詢其在SQL服務器管理工作:如何使用sql命令更新vb.net中的sql表?
Update SQLTableBlokke
set blokgemiddeld = ((tha_min4 + tha_min3 + tha_min2 +
tha_min1 + tha_huidig)/
NULLIF(((ABS(sign(tha_min4))+ABS(sign(tha_min3))+ABS(sign(tha_min2))+
ABS(sign(tha_min1))+ABS(sign(tha_huidig))) * 1.00),0))
作爲一個初學者我有使用此命令爲vb.net命令的麻煩。我曾嘗試以下:
Dim konneksie As New SqlConnection
Dim opdraggem As New SqlCommand
konneksie.ConnectionString = "Data Source=GIDEON-E- LAPTOP\SQLEXPRESS2014;Initial Catalog=BlokwinsgewendheidDatabasis;Integrated Security=True"
konneksie.Open()
opdraggem.Connection = konneksie
opdraggem.CommandText = "Update(SQLTableBlokke)" & _
"blokgemiddeld = @((tha_min4 + tha_min3 + tha_min2 + tha_min1 + tha_huidig)/" & _
" NULLIF(((ABS(sign(tha_min4)) + ABS(sign(tha_min3)) + ABS(sign(tha_min2)) + ABS(sign(tha_min1)) + ABS(sign(tha_huidig))) * 1.0), 0)) "
opdraggem.ExecuteNonQuery()
但是我得到的錯誤信息:附加信息:。附近有語法錯誤('光標停在opdraggem.ExecuteNonQuery()行
我想我有使用的參數,但不知道如何實現它們。
到新手任何幫助將非常感激。
你在你的vb代碼中缺少關鍵字「set」opdraggem.CommandText = – Neal
我不認爲你複製了命令,因爲SET和一些空格缺失......爲了避免錯誤,只需將其粘貼到一行即可。 –