.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to call a Select statement Stored Procedure using SqlDataAdapter?

Posted By:Syed Shakeer Hussain       Posted Date: August 17, 2009    Points: 25    Category: C#    URL: http://www.dotnetspark.com  

Creating a select statement storedprocedure:


select * from emp

Here 'selectemp1' is a procedure name and emp is the Table name.

How to call a Procedure name usign SqlDataAdapter and display the data in Gridview:

SqlConnection conn = new SqlConnection("Data Source=INTHIYAAZ;Initial Catalog=shakeer;User ID=sa;Password=sa");

//calling the stored procedure name 'selectemp1' in sqlcommand
        SqlCommand cmd = new SqlCommand("selectemp1",conn );
        SqlDataAdapter adapter = new SqlDataAdapter(cmd );
        DataSet ds = new DataSet();
        GridView1.DataSource = ds.Tables[0];

output of the Gridview Image:

Thanks for Reading Article!

Syed Shakeer Hussain


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend