Please help with parameters for queries

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2006
Posts: 23
Reputation: Seba Sama is an unknown quantity at this point 
Solved Threads: 1
Seba Sama Seba Sama is offline Offline
Newbie Poster

Please help with parameters for queries

 
0
  #1
Sep 29th, 2008
Hi

I'm currently using data binding, combo boxes, grids...
I need to filter the data in a DataGridview depending on a value selected in a combo box. The combo is bound to a table, displaying data from a particular column, while the datagrid needs to "query" a second table "...WHERE condition = <combo value>".
If I add a parameter in the query a text box appears on my form. Is there a way to pass the value returned by the combo as a parameter for the datagrid query ?

Or perhaps another way to work with data without recordsets?
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 23
Reputation: Seba Sama is an unknown quantity at this point 
Solved Threads: 1
Seba Sama Seba Sama is offline Offline
Newbie Poster

Re: Please help with parameters for queries

 
0
  #2
Sep 29th, 2008
Never mind, i got it done.
I set a parameter in the query. VB automatically adds a toolstrip with a box for the @param1. I used a text box for @param1
  1. Private Sub FillBy_textToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillBy_textToolStripButton.Click
  2. Try Me.Tbl_ERP_PRODUCTION_ORDERSTableAdapter.FillBy_text(Me.SITEQDataSet.tbl_ERP_PRODUCTION_ORDERS, TextToolStripTextBox.Text)
  3. Catch ex As System.Exception
  4. System.Windows.Forms.MessageBox.Show(ex.Message)
  5. End Try
  6.  
  7. End Sub

Now I set the same for the text box:
     Private Sub txtOrder_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtOrder.TextChanged
        If txtOrder.TextLength < 4 Then Exit Sub
        Try
            Me.Tbl_ERP_PRODUCTION_ORDERSTableAdapter.FillBy_text(Me.SITEQDataSet.tbl_ERP_PRODUCTION_ORDERS, txtOrder.Text)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub

that len check is for a live filter
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC