我有兩個單獨的INSERT語句,我想依次運行, 第一個成功運行,但它似乎甚至沒有得到第二個語句的任何想法爲什麼?執行兩個INSERT語句
Try
con.Open()
cmd.ExecuteNonQuery()
resultSQL.ForeColor = Drawing.Color.Green
resultSQL.Text = "Successfully Saved"
Catch ex As Exception
Response.Write(ex.Message)
resultSQL.ForeColor = Drawing.Color.Red
resultSQL.Text = ex.Message
Finally
End Try
INSERT 2其中沒有運行:
strQuery = "INSERT INTO [SD_EPOS_Entry]" _
& " ([Trade_Activity_Code] " _
& " VALUES " _
& " (@Trade_Activity_Code1)"
cmd = New SqlCommand(strQuery)
cmd.Parameters.AddWithValue("@Trade_Activity_Code1", tcodeVar)
Try
con.Open()
cmd.ExecuteNonQuery()
resultSQL.ForeColor = Drawing.Color.Green
resultSQL.Text = "Successfully Saved2"
Catch ex As Exception
Response.Write(ex.Message)
resultSQL.ForeColor = Drawing.Color.Red
resultSQL.Text = ex.Message
Finally
由於您在上一次插入中沒有關閉它,是否'con'已經打開?你在那部分出現錯誤嗎? –
@ shree.pat18好點!我會糾正這個問題,不會產生錯誤 – neeko
你能展示整個方法嗎? – Crono