i want to make a search box and when the user for something i want it to search it the databse and show the resultat. can someone help me how we do this with the code.
tanks
i want to make a search box and when the user for something i want it to search it the databse and show the resultat. can someone help me how we do this with the code.
tanks
How to retrive from a databbase using vb.net
Warren13
well you pretty much write your SQL query in there in the SQLCommand, or if you are using a StoredProcedure, just write the name of the stored procedure and changing the "CommandType" to "StoredProcedure" in the SQLCommand.
so in the example, I was just getting all the records from a table (with a search criteria), and filling the dataAdapter with results
Equis
YCDC.CN
ronks
basically you will take the input from the textbox and make a query on it:
SELECT * FROM someTable WHERE SomeColumn LIKE textboxInput
this query will be placed in the SqlCommand object.
you will also use a connectionstring to connect to SQL using the SqlConnection Class.
You open the connection using the SqlConnection close, and either:
1) read the values returned using an SqlDataReader
2) fill a dataset with data/results returned back from SQL using the SqlDataAdapter class and "filling" a dataset
then you close the connection and either:
1) bind the results to a datagridview
2) use your own way to go through each row of data in the dataset or something like this
byronfromwesleyan
Huseyin Akturk
I have given an example in my code ;-) To me it seems you do not know SQL Server, so I would suggest you learn about it :-)
It is mandatory these days to know SQL Server.
a SQL Server query is just a query which returns results (for example) with a certain criteria, as I had posted.
JesseD70
Example:
Dim theSQLCommand as new SqlCommand("SELECT * FROM someTable WHERE SomeColumn LIKE '%" + yourTextBoxValue + "%'")
theSQLCommand.Connection = new SqlConnection(yourConnectionString)
Dim theDataSet as new DataSet()
Dim theSQLDataAdapter as new SqlDataAdapter(theSQLCommand)
try
theSQLCommand.Connection.Open()
theSQLDataAdapter.Fill(theDataSet)
theSQLCommand.Connection.Close()
Me.theDataGridView.DataSource = theDataSet.Tables(0).DefaultView
catch ex as SqlException
'handle exception
end try
this is just an example which will do the following:
bkejser
Here is the link to the Starter Kits. Choose the one which best fits your needs. Good luck.
Sneak
Steve Whitley