Hey all,
I have a dataset of search results that I want to put into a datagrid on another form, then allow the user to select one row and fill in textboxes on the main form with that row's data.
Here's what I have so far...this is the code on the main form for my search button. It works fine filling in the textboxes from the dataset on the form this button is on, I just need to know how to populate the datagrid(grdCustSearch) in the other form(frmCustSearch) with the first two columns of dss:
Thanks in advance.VB Code:
Private Sub btnCustomerSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCustomerSearch.Click Dim srch As String Dim sqls As String Dim dss As New DataSet Dim das As New Odbc.OdbcDataAdapter Dim csreturn As New frmCustSearch Try srch = txtCustomerSearch.Text sqls = "SELECT * FROM customer WHERE LOWER(customername) LIKE '%" & srch.ToLower & "%' ORDER BY customername ASC;" das = New Odbc.OdbcDataAdapter(sqls, con) dss.Clear() das.Fill(dss, "customer") 'Something to fill the datagrid in the other form goes here; I just KNOW it! 'These were used to fill in the textboxes on the current form 'And they still will be, but from the dataset on the new form 'txtCustomerName.Text = dss.Tables("customer").Rows(0).Item(0) 'txtCustomerNumber.Text = dss.Tables("customer").Rows(0).Item(1) csreturn.ShowDialog() csreturn.Dispose() Catch ex As Exception MessageBox.Show("No record found", "No Record", MessageBoxButtons.OK) End Try End Sub
CP





Reply With Quote