Hi, i'm working with a sql (2005) database and using visual studio 2010. I've created a system where one of the forms is a find/search form. A user can enter in for example, a customerID and once they click on "find/search" the customerID will be searched in the database and if found, all relevant information about the customer will be retrieved and displayed in another form (find/search results page). I realise that this can be done using an SQL statement like follows

searchStr = "SELECT * FROM Customer WHERE CustomerID LIKE CIDTextBox.Text%"

What i'm unsure about is how to execute this SQL statement once the "find/search" button has been clicked and how to display the founded results in another form.
I've been wrecking my brain over the past few days on how to do this as i'm new at using vb and sql. Any help on this would be greatly appreciated!

Thanks in advance,
Sacha

hi its easy.. create a property in the page where u want to display the result..

set this property to your sql query from search page then on the load event of the result page run this query

Hi, sorry, you'll have to excuse my ignorance when it comes to this am i'm very new at it. Would you happen to know of a good tutorial that I could look at so I can go through it step by step?

Thanks!

sandeepparekh9, sadly I couldn't get it to work. I've made some progress since then but i've yet to figure out why i'm doing it wrong ..

Below is the code I have so far (in the FindSearchPage)

Private Sub FindBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindBtn.Click
 Dim SelectedRowView As Data.DataRowView
    Dim SelectedRow As CustomerSearchDataSet.CustomerRow

    SelectedRowView = CType(CustomerBindingSource.Current, System.Data.DataRowView)
    SelectedRow = CType(SelectedRowView.Row, CustomerSearchDataSet.CustomerRow)

    Dim CustomerForm As New FindSearchResultsPage
    CustomerForm.LoadCustomer(SelectedRow.customerID)
    CustomerForm.Show()


End Sub

And in FindSearchResultsPage I have,

Friend Sub LoadCustomer(ByVal CustomerID As String) 'TODO: This line of code loads data into the 'CustomerSearchDataSet.Customer' table. You can move, or remove it, as needed. Me.CustomerTableAdapter.FillByCustomerID(Me.CustomerSearchDataSet.Customer, CustomerID)

End Sub

FillByCustomerID is the query I created to fill the FindSearchResultsPage with all customer information.

I'm unsure how to grab the data and i'm aware that the SelectedRowView doesn't contain anything when it runs. Is there a way that I can fix this?

I also tried another alternative but I got nowhere:

drCustomer (datarow ive created) = CustomerSearchDataSet.Tables("Customer").Rows.Find(CIDTextBox.Text) <-- name of text box within FindSearchPage

--> name of text box within FindSearchResultsPage - customerID.Text = drCustomer("customerID")

If you could share any light on this, I would greatly appreciate it! Thanks in advance, Sacha

This article has been dead for over six months. Start a new discussion instead.