I was currently working on a project and wants to load the called data on the datagridview upon form_load, But I wasn't sure why the supposed data wasn't loading. Attached are my codes, could you help me pinpoint whats wrong with this? Needed it badlly.
Code:
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = GetV9_data();
}
private DataTable GetV9_data()
{
DataTable V9db = new DataTable();
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source = 10.47.48.80; Initial Catalog = V9_Hirata_L2; User ID = Guest; Password = ************;";
SqlCommand cmd = new SqlCommand("Select ID, MotorSN, StationNo, PT_NestNo, PT_TS_AW_Pin_1, PT_TimeIn FROM tbl_V9_Datalog", conn);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
V9db.Load(reader);
return V9db;
}