Here is the most basic and easy way to represent data in the grid view form.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.SqlClient; using System.Data.SqlTypes; namespace FormsApplication1 { publicpartialclassForm4 : Form { public Form4() { InitializeComponent(); } publicvoid fill() { SqlConnection con3 = newSqlConnection(); con3.ConnectionString = (@"Data Source=msclient-012\sqlexpress;Initial Catalog=testing_st;User
ID=sa;Password=mindstick"); DataSet ds = newDataSet(); con3.Open(); SqlCommand cmd = newSqlCommand("select
A.Enrollment_number,A.Student_name,A.Father_Name,A.Mother_Name,A.Sex,A.Permanent_Add,A.Permanent_State,B.Subject_Maths,B.Subject_Physics,B.Subject_Chemistry,B.Subject_English,B.Subject_Hindi,B.Subject_Social,B.class
FROM Std_Details A,Std_Opt_Sub B where A.Enrollment_number =
B.Enrollment_number",
con3); SqlDataAdapter da = newSqlDataAdapter(); da.SelectCommand = cmd; da.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; } } }
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Here is the most basic and easy way to represent data in the grid view form.