hi! i'm a new programmer and i was wondering.. how can you search using a textbox and the output comes out on the datagrid for example: I typed the letter "A" and all the names of a certain column, which starts with letter "A" is shown.. then i typed "B" so the textbox contains "AB" then all the names that starts with "AB" are shown in the datagrid.
can you help me? thanks :)
Loading
Bechir BejaouiPosted Jul 12, 2008, 10:46 AM
CREATE PROCEDURE Search @letter Char
AS
Select [something here] from [something here] where [your targeted field] like @letter
GO
Then create a connection to your data base
create a command
sqlCommand oCommand = new sqlCommand("Search");//Remarque that we use the name of the stored procedure
oCommand .CommandType = CommandType.StoredProcedure;
//Now create an sql param
sqlParameter myParam = new sqmParameter("@letter", sqlDBtype.Char);
myParam.Value = textbox.text;
oCommand.Parameters.add(myParam);
//now create a data set to stock data wirth
DataSet ds = new DataSet();
//An sqldataadapter to fill the dataset
sqlDataAdapter oAdapter = new sqlDataAdapter(oCommand);
//Fill the data into data set
oAdapter.Fill(ds);
//Now tie your control to the dataset
dataGridview.dataset = ds;
dataGrifView.datamember = ds.Tables[0].TableName
try it