Hi There,
I have a onclick event on my
vb.net form.
I have two text box, OTBOX AND OTEND.
I want the users to enter two order #s one one each of the two text box. I want to use these order #s as input to my querry which has a WHERE clause with has a between criteria.
I have hard coded two WO# FOR THE BETWEEN CONDITION TO CHECK. IT was fine, but I want to be able to use the input from the text box.
System.Data.OleDb.OleDbDataAdapter("Select [WO #], [Dash #], Req AS [Order DT], Approved, Code, [Item#], Cus,ID from Approve where [WO #] between 136300 and 136400 ORDER by [WO #] ", myConnection)
I WANT TO BE ABLE TO USE THE USERS INPUT ON OTBOX.TEXT AND OTEND.TEXT
IN PLACE OF 136300 AND 136400.
I would appreciate if anybody can tell me how I can do that.
Please find below the entire onclick event.
Please find my code below
Private Sub ORDBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ORDBTN.Click
'lboResults.Items.Clear()
Try
' create a connection string
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\ USE.mdb"
Dim myConnection As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection
myConnection.ConnectionString = connString
' create a data adapter
Dim da As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter("Select [WO #], [Dash #], Req AS [Order DT], Approved, Code, [Item#], Cus,ID from Approve where [WO #] between 136300 and 136400 ORDER by [WO #] ", myConnection)
I tried this doesn't work
' da.SelectCommand.Parameters("[WO #]").Value() = OTBOX.Text ' create a new dataset
Dim ds As DataSet = New DataSet
' fill dataset
da.Fill(ds, "Approve")
Me.DataGrid1.DataSource = ds.Tables("Approve").DefaultView
Catch ex As Exception
MsgBox(ex.Message + vbCrLf + ex.Source & vbCrLf & vbCrLf & ex.StackTrace, MsgBoxStyle.Critical, "Error")
End Try
End Sub