我有一张价格表,并且所有价格都是“客户”支付的
| ID | Price |
|----|-------|
| 1 | 5.00 |
| 50 | 6.70 |
当你在文本框中输入3或3.00时,我想制作一些东西,然后它会显示超过该值的所有记录,因此ID
1支付5 quid然后它们将显示并与{{1我希望它们显示在我的datagridview中。
到目前为止我所拥有的是:
ID
答案 0 :(得分:0)
我已按如下方式更改您的代码:
myDA = New OleDbDataAdapter
myDataSet = New DataSet
Dim price As Double = Convert.ToDouble(TextBox1.Text)
'Save the value entered in textbox on the variable price
Try
cmd = New OleDbCommand()
cmd.CommandText = "Select ID,Price from tableName where Price > @Price "
'tableName should be replaced with the name of your table
cmd.Parameters.AddWithValue("@Price", price)
'Add parameter to pass the price to the query
cmd.Connection = con
If con.State = ConnectionState.Closed Then con.Open()
myDA.SelectCommand = cmd
myDA.Fill(myDataSet, "tableName")
DataGridView1.DataSource = myDataSet.Tables("tableName").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try