当前位置: 动力学知识库 > 问答 > 编程问答 >

Another - Must declare the scalar variable @TDate Vb.Net

问题描述:

I have searched long and hard on this issue and can't come up with anything that works! Please can you help me? What am I doing wrong to cause this error? Must "declare the scalar variable @TDate" I am updating two dates - dob and transfersate. In this case transferdate in the sql table and TDate a date value from a date control.

Using SQLCmd As New SqlClient.SqlCommand("UPDATE member SET "DOB = @DOB, [email protected] WHERE mid =" & MID, SQLCon)

SQLCmd.Parameters.Add("@transferdate", SqlDbType.Date)

SQLCmd.Parameters("@transferdate").Value = TDate

SQLCmd.Parameters.AddWithValue("@DOB", DOB)

i = SQLCmd.ExecuteNonQuery

End Using

网友答案:

In you sql query you refer to the variable @TDate in the bit [email protected]. You add SQLParameters to your cmd, but the parameter you add is called @transferdate.

Try changing this bit of code here:

            SQLCmd.Parameters.Add("@transferdate", SqlDbType.Date)
            SQLCmd.Parameters("@transferdate").Value = TDate

to this instead:

            SQLCmd.Parameters.Add("@TDate", SqlDbType.Date)
            SQLCmd.Parameters("@TDate").Value = TDate    
分享给朋友:
您可能感兴趣的文章:
随机阅读: