query dataset
-
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbcondatasets.asp[^] Read the section on Populating Datasets and follow the links on data adapters. Marc My website
Latest Articles: Object Comparer String Helpers -
If you've already got a populated dataset, you could do the following: Let's say you got a DataSet (ds) with a 'Customer' Table, and you want all the customers that have a first name of 'Paul' DataView dv = new DataView(ds.Tables["Customer"]) ; dv.RowFilter = "FirstName = 'Paul'" ; Now, you have records that have 'Paul' in the FirstName field, in your DataView. Is that what you meant?
-
If you've already got a populated dataset, you could do the following: Let's say you got a DataSet (ds) with a 'Customer' Table, and you want all the customers that have a first name of 'Paul' DataView dv = new DataView(ds.Tables["Customer"]) ; dv.RowFilter = "FirstName = 'Paul'" ; Now, you have records that have 'Paul' in the FirstName field, in your DataView. Is that what you meant?
-
hmm..maybe yes i have dataset already populated but is there a way to execute a sql command on dataset data
Yes. ** To execute a stored procedure, that gets the value of an output parameter //you need to have a SqlConnection object SqlCommand something = new SqlCommand("StoredProcName",[sqlConnection]) ; something.CommandType = CommandType.StoredProcedure ; //for each paramter in the stored proc, do the following something.Parameters.Add(@Parm1, SqlDbType.Int) ; something.Parameters["@Parm1"].Direction = ParameterDirection.InputOutput ; something.Parameters["@Parm1"].Value = [in this case an integer value] ; something.ExecuteNonQuery() ; Int32 somevalue = Convert.ToInt32(something.Parameters["@Parm1"].Value) ; ** there are many ways to deal with executing Sql Commands. You can set up a SqlCommand for dataadapters for automatically updating your dataset, you can also use SqlCommand to just execute a sql statement. Look in your MSDN help for more info on this, or search CodeProject articles ... there are lots of them on this issue.
-
hmm..maybe yes i have dataset already populated but is there a way to execute a sql command on dataset data
You can use the Select() of a datatable...
// create and populate a dataset DataSet ds = new DataSet(); DataTable table = ds.Tables.Add(); table.Columns.Add("Name", System.String); table.Columns.Add("Value", System.String); table.Rows.Add(new string[] {"David", "one"}); table.Rows.Add(new string[] {"George", "two"}); // call DataTable.Select() to get all rows with name starting with 'D' DataRow[] resultRows = table.Select("Name Like 'D%'");
Hope it helps! -Cursor -
You can use the Select() of a datatable...
// create and populate a dataset DataSet ds = new DataSet(); DataTable table = ds.Tables.Add(); table.Columns.Add("Name", System.String); table.Columns.Add("Value", System.String); table.Rows.Add(new string[] {"David", "one"}); table.Rows.Add(new string[] {"George", "two"}); // call DataTable.Select() to get all rows with name starting with 'D' DataRow[] resultRows = table.Select("Name Like 'D%'");
Hope it helps! -Cursor