我有SQL數據庫表以下數據:指數超出範圍。必須是非負數且小於集合的大小。參數名:指數-6
BillNo Particular Price Unit Amount Taxamount Tax
2905 Airfreight 100.000 100 10000.000 0.000 0.000
2905 Customs 4500.00 1 0.000 4500.000 675.000
2906 THC 250.000 1 0.000 250.000 38.000
2906 XYZ 5000.00 1 5000.000 0.0000 0.0000
在一個窗口的形式我有一個由比爾號搜索名爲Tbblbillto.Text
文本框和一個DataGrid。當我在文本框中鍵入賬單號碼時,如何使SQL表格中的數據根據賬單號碼進行過濾,然後將其放入數據網格中?
*Data Grid Table*
**Particular Price Unit Amount Taxamount Tax**
Private Sub Tbblbillto_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tbblbillto.TextChanged
Dim Cmd As New SqlClient.SqlCommand
Dim Con As New SqlClient.SqlConnection
Dim Rd As SqlDataReader
Con.ConnectionString = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=dbase;Integrated Security=True;Pooling=False"
Cmd.Connection = Con
Con.Open()
Dim Row As New DataGridViewRow
Dim Int As Integer
Row = Dgvbillsa.Rows(Int)
Cmd.CommandText = "Select * from BillDetails Where BillNo = '" & Tbblbillto.Text & "'"
Rd = Cmd.ExecuteReader
Rd.Read()
If Rd.HasRows Then
Row.Cells(0).Value = Rd.Item("Particular")
Row.Cells(1).Value = Rd.Item("Price")
Row.Cells(2).Value = Rd.Item("Unit")
Row.Cells(3).Value = Rd.Item("Amount")
Row.Cells(4).Value = Rd.Item("TaxAmount")
Row.Cells(5).Value = Rd.Item("Tax")
End If
End Sub
我的我的,看所有的SQL注入漏洞。 – Will
我不瞭解你的觀點 –
如果用戶輸入'',會發生什麼?將表格BillDetails放入文本框中? –