Check if item is contained in column of a datatable in 2005


I have the following code:-

        SQL = "Select * from Locations"
        Dim da As New SqlClient.SqlDataAdapter(SQL, oConn)
        da.Fill(ds, "Locations") ' populate data set "da" with the data returned from sql command "ds" and set dataset name to "Rigs"
        DataGridView1.DataSource = ds.Tables("Locations")

Basically it returns 3 columns - locationID, Stock_Location and Location_Description and places the retrieved data into a datatable. I am trying to find out how I can check if the string in textbox1.text is already in the column Stock_Location please in the datatable

Many thanks
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

DhaestConnect With a Mentor Commented:
I see 2 possibilities:

1. Perform it with a sql-statement: SQL = "Select * from Locations where Stock_Location '" & Textbox1.Text & "'"
2. Filter your dataset
ds.Tables("Locations").DefaultView.RowFilter = "Stock_Location =''" & Textbox1.Text & "'"
if ds.Tables("Locations").DefaultView.Count > 0 then
  --> record found
All Courses

From novice to tech pro — start learning today.