|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
can i use dynamic variable inside a dataadapter and bind to datagridHi
I want to use a sql designed in the dataadapter and I want to pass a variable so it can retrieve related data by using "WHERE" clause in the sql statement. You can use command object to pass parameter to sql query.
SqlConnection conn = new SqlConnection(CONNECTIN_STRING); SqlCommand command = conn.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = "SELECT * FROM Table_Name WHERE field_Name = @parameter"; command.Parameters.Add("@parameter",value); SqlDataAdapter dap = new SqlDataAdapter(command); HTH Elton Wang elton_w***@hotmail.com >-----Original Message----- want to pass a>Hi > >I want to use a sql designed in the dataadapter and I >variable so it can retrieve related data by using "WHERE" clause in the sqlShow quoteHide quote >statement. > > >. > So add a parameter to the DataAdapter.SelectCommand.Parameters collection:
DataAdapter1.SelectCommand.CommandText = "select * from foo where bar = @bar"; DataAdapter1.SelectCommand.Parameters.Add("@bar", "some value"); -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > Hi > > I want to use a sql designed in the dataadapter and I want to pass a > variable so it can retrieve related data by using "WHERE" clause in > the sql statement. >
How can I display hashtable key values in a web page?
Move bound column to right of dynamic column in datagrid? Print WebForm DataGrid To Eliyahu Dynamically Add Validation to Datagrid problem exporting datagrid to excel How to pull the data out from two table and bind to repeater User Control ASP .Net Message box help Needed Very urgent SortCommand and PageIndexChange event not firing |
|||||||||||||||||||||||