loading data from database to datagridview
hello there
I'm trying to load data from my sql server database to a daatagriedview on my windows form application but its not loading pls help me here is my code
private void findBtn_Click(object sender, EventArgs e)
{
// loading data from the database
string connectionString = @"Data Source=JEREMIAH-HP\sqlexpress;Initial Catalog=CourseInfo;
Integrated Security=True";
SqlConnection sqlCon = new SqlConnection(connectionString);
sqlCon.Open();
string commandString = "select * from STUDINFO_TBL where MATRICNO='" + entmatno.Text + "'"+
"SELECT * from COURSEINFO_TBL WHERE MATRICNO='" + entmatno.Text +"'";
SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);
SqlDataReader read = sqlCmd.ExecuteReader();
SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dataTable = new DataTable();
while (read.Read())
{
mNo.Text = read["MATRICNO"].ToString();
fName.Text = read["FIRST_NAME"].ToString();
lName.Text = read["LAST_NAME"].ToString();
Dept.Text = read["DEPT"].ToString();
level.Text = read["LEVEL"].ToString();
cgpa.Text = read["CGPA"].ToString();
dgvresult.DataSource = da;
dgvresult.Columns[0].Name = "MATRICNO";
dgvresult.Columns[1].Name = "CRS_CDE";
dgvresult.Columns[2].Name = "CRS_UNT";
dgvresult.Columns[3].Name = "CRS_PNT";
dgvresult.Columns[4].Name = "CRS_SCRE";
dgvresult.Columns[5].Name = "CRS_GP";
}
read.Close();
}
please where I'm i missing it?