Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Run mode screen in datagridview as follows; Load(Button)

i have one button called Load.

Date Session NR PN GS

28-Jan 1 REO PH2 TASCO
28-Jan 2
28-Jan 3
28-Jan 4
29-Jan 1
29-Jan 2 AFF MFA CTF
29-Jan 3
29-Jan 4
30-Jan 1
30-Jan 2
30-Jan 3 TFC LGTF ECDIS
30-Jan 4
31-Jan 1
31-Jan 2
31-Jan 3
31-Jan 4 ERSM ARPA REO
1-Feb 1 PH2 TASCO AFF
1-Feb 2
1-Feb 3
1-Feb 4
2-Feb 1
2-Feb 2 MFA CTF TFC
2-Feb 3
2-Feb 4

all the above details are entered in the datagridview and save it in the database.
it is working fine no problem.


then i switch off my system today.

Next day i open my project and run this screen.
when i click the Load button all the data's i entered in the datagridview in the previous day that data's to be shown in the datagridview.


for that how can i write the code.please help me.

Database Design as follows;

Sch_Date Date/Time
Session Number
course Text
Faculty_Code Text

Tablename Schedule.

in the schedule table all the details are saved in the database.

when i click the load button output as follows;

Date Session NR PN GS

28-Jan 1 REO PH2 TASCO
28-Jan 2
28-Jan 3
28-Jan 4
29-Jan 1
29-Jan 2 AFF MFA CTF
29-Jan 3
29-Jan 4
30-Jan 1
30-Jan 2
30-Jan 3 TFC LGTF ECDIS
30-Jan 4
31-Jan 1
31-Jan 2
31-Jan 3
31-Jan 4 ERSM ARPA REO
1-Feb 1 PH2 TASCO AFF
1-Feb 2
1-Feb 3
1-Feb 4
2-Feb 1
2-Feb 2 MFA CTF TFC
2-Feb 3
2-Feb 4


how can i do?how can i write the code.please help me.

Thanks & Rgds,
Narasiman P
Posted
Comments
Sandesh M Patil 30-Jan-13 7:56am    
Are you asking how to bind the datagrid on the click of load button?

1 solution

Try below code on click of Load button

string query = "SELECT * FROM Person";
        SqlDataAdapter da = new SqlDataAdapter(query, connection);
        SqlCommandBuilder cb = new SqlCommandBuilder(da);
        DataTable dt = new DataTable();
        da.Fill(dt);
        BindingSource bs = new BindingSource();
        bs.DataSource = dt;
        dataGridView1.DataSource = bs;
 
Share this answer
 
Comments
Espen Harlinn 30-Jan-13 8:10am    
5'ed! :-D
Sandesh M Patil 30-Jan-13 8:17am    
thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900