我在ASP.NET中使用VB进行编码
我的SQL Server数据库表名称TempPurchases有3列:
- ItemNumber(nvarchar(10),null)
- RDC(nvarchar(2),null)
- PurchaseQTY(int,null)
进入表格的用户输入是:ItemNumberTxtBox,DropDownList1,QuantityTxtBox
这是我的代码:
Protected Sub AddButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click
Dim CON As New SqlConnection("server=blahblah.com;database=databasename;User ID=fffffff;Password=*******;")
Dim SQL As String = "INSERT INTO TempPurchases (ItemNumber, RDC, PurchaseQTY) VALUES (@ItemNumber, @RDC, @PurchaseQTY) "
Dim CMD As New SqlCommand(SQL, CON)
CMD.Parameters.Add(New SqlParameter("@ItemNumber", SqlDbType.NVarChar, 10))
CMD.Parameters("@ItemNumber").Value = ItemNumberTxtBox.Text
CMD.Parameters.Add(New SqlParameter("@RDC", SqlDbType.NVarChar, 2))
CMD.Parameters("@RDC").Value = dropdownlist1.SelectedValue
CMD.Parameters.Add(New SqlParameter("@PurchaseQTY", SqlDbType.Int))
CMD.Parameters("@PurchaseQTY").Value = QuantityTxtBox.Text
CON.Open()
CMD.ExecuteNonQuery()
CON.Close()
End Sub
我做错了什么?我没有收到错误消息,但没有任何内容输入数据库表。