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


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

View data in a grid view

Posted By: nmohammed     Posted Date: October 16, 2011    Points:5   Category :C#
Hi, i am new to C#, i need to view the data inserted in the database in a grid view
i have done this code , can some one help me finish it plz
[CODE]
public DataSet PMEWDirectorates_GetAll()
{
SqlConnection con = new SqlConnection();
SqlCommand com = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
try
{
con.ConnectionString = conString;
con.Open();
com.Connection = con;
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "PMEWDirectorates_GetAll";
da.SelectCommand = com;


com.Parameters.AddWithValue("@ID", DBNull.Value);
com.ExecuteNonQuery();
da.Fill(ds);
return ds;

}
catch
{
return ds;
}
finally
{
con.Close();
ds.Dispose();
da.Dispose();
com.Dispose();
con.Dispose();
}

}
[/CODE]

Thank you

Responses
Author: Narayanan             
Posted Date: October 17, 2011     Points: 20   

Hi,
dataGridView1.DataSource = ds;
Regards
Lakshmi Narayanan.S

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: williams             
Posted Date: October 31, 2011     Points: 20   

hi,

thanks for the simple coding as dataGridView1.DataSource = ds; because we can use this to display the data in the whole grid.

website development firm in india
_____________________________________

website development firm





Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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