Dear all

I am working on a project for my customer .
I wrote code to search items from sql using vb.net

Now my code working fine.....when I search data using itemid it show me data in all related textboxes but not in datagrid

here my code

    Dim connection As New SqlConnection("Server= DESKTOP-QN6F623; Database = dbo_main; Integrated Security = true")

    Dim command As New SqlCommand("select * from items where itemnumber=@itemnumber", connection)

    command.Parameters.Add("@itemnumber", SqlDbType.Int).Value = ItemnumberTextBox.Text

    Dim adapter As New SqlDataAdapter(command)

    Dim table As New DataTable()

    adapter.Fill(table)

    ItemnameTextBox.Text = ""

    If table.Rows.Count() > 0 Then

        ' return only 1 row
        ItemnameTextBox.Text = table.Rows(0)(1).ToString()
        ItembarcodeTextBox.Text = table.Rows(0)(2).ToString()
        ItemnameTextBox.Text = table.Rows(0)(3).ToString()
        ItemdescriptionTextBox.Text = table.Rows(0)(4).ToString()
        ItemcolorTextBox.Text = table.Rows(0)(5).ToString()
        ItemsizeTextBox.Text = table.Rows(0)(6).ToString()
        ItemmaterialComboBox.Text = table.Rows(0)(7).ToString()
        ItemavailablestockTextBox.Text = table.Rows(0)(8).ToString()
        ItempricesTextBox.Text = table.Rows(0)(9).ToString()
        ItemsuppliersTextBox.Text = table.Rows(0)(10).ToString()
        ItembrandnameComboBox.Text = table.Rows(0)(12).ToString()
        ItemlocationComboBox.Text = table.Rows(0)(13).ToString()

    Else

        MessageBox.Show("NO Data Found")

    End If

I only want to show searched data in textboxes as well as in datagrid with high lighted....

please guide

thanks in advance

You have not provided any information about what fields are in you datagrid or what you want displayed.
If the datagrid uses the samew data as your query, you need this (assuming the datagrid name is DG):

DG.DataSource=table
DB.DataBind()

HTH,
Sean

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.