TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Fadugba Jeremiah
NA
49
18.1k
loading data from database to datagridview
Nov 12 2013 8:12 AM
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?
Reply
Answers (
1
)
Using Enter Key Instead Of Tab Key In asp.net textBox Contro
Linking forms together