cs_dataset-sp.cs This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters string CS = ConfigurationManager . ConnectionStrings [ "test_connectionString" ] . ConnectionString ; using ( SqlConnection con = new SqlConnection ( CS ) ) { SqlDataAdapter da = new SqlDataAdapter ( "testProcedure3" , con ) ; // Using a Store Procedure. //SqlDataAdapter da = new SqlDataAdapter("SELECT 'this is a test text' as test", con); To use a hard coded query. da . SelectCommand . CommandType = CommandType . StoredProcedure ; // Comment if using hard coded query. DataSet ds = new DataSet ( ) ; // Definition: Memory representation of the database. da . SelectCommand . Parameters . AddWithValue ( "@ggg" , 95 ) ; // Repeat for each parameter present in the Store Procedure. da . Fill ( ds ) ; // Fill the dataset with the query data GridView1 . DataSource = ds ; // Set the dataso... meh, you get it. GridView1 . DataBind ( ) ; //TextBox1.Text=GridView1.Rows[0].Cells[0].Text; If you want to pass the data to another element. }

C# - Calling a SQL Server Stored Procedure. Using a dataset to get the data.
Akshay Kumar


