954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C#

I create a simple data base table using Microfoft SQL Server 2005 and i want to display this simple table as a hole in my form.I use DataSet and DataAdapter to communicate with my SQL data base.i try to pull all the record at data base in to the DataSet by using the interface of DataAdapter,up to this i haven't any problem.My problem is to pull the record from the DataSet in to the Form or directly from the data base to a Form.
this is my code

System.Data.SqlClient.SqlConnection con;
        DataSet ds;
        System.Data.SqlClient.SqlDataAdapter da;
       con = new System.Data.SqlClient.SqlConnection();
           ds = new DataSet();
            string sql = "SELECT* From Table1";
            da = new System.Data.SqlClient.SqlDataAdapter(sql, con);
         con.ConnectionString = "Data  Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database1.mdf;Integrated Security=True;User Instance=True";

            con.Open();
 da.Fill(ds, "Table1");
con.Close();

where "Table1" is the name of my table in the data base.
Thank you!
With best regards.

Girum1
Newbie Poster
1 post since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

I think you want to show records onto the form.

Add DataGridView control and write following code.

datagridview1.DataSource=ds;
 datagridview1.DataMember="Table1";
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: