If you are looking to pull out just one value (field) then this is simple enough. But databases are not like that, they're linked to different tables. How they are linked will depend on how easy it is to get the correct data out.
In Total how many tables do u need to do search operation..?
If Many Tables, and many recs in each table, then this will be a huge Overhead on the database.
But if u need to do it compulsorily, Write a Stroredprocedure which accepts Search String. And Checks each table and returns Table Name/id/fieldname if found..
Using the stored Procedure from the link QVeen72 provided I have been able to get the search results I want with in SQL.
My problem is getting this to display in vb.net in a data grid.
Can anyone offer some help as to where to look for a solution.
The code I am using at the moment is:
Dim cs As String = "Data Source=.\SQLEXPRESS;Initial Catalog=Database;Integrated Security=True"
Using con As New System.Data.SqlClient.SqlConnection(cs)
Dim cmd As New System.Data.SqlClient.SqlCommand()
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "SearchAllTables"
cmd.Parameters.Add("@SearchStr", SqlDbType.NVarChar, 12)
cmd.Parameters("@SearchStr").Value = TextBox1.Text
Using reader As System.Data.SqlClient.SqlDataReader = cmd.ExecuteReader()
DataGridView1.DataSource = reader
The information I have see says that the last line should add: DataGridView1.DataBind, but I do no seem to have this as an option and it does not work if there is.