//loads list with data void loadJobCardRows() { JobCardRows.Clear(); myConnection = new SqlConnection(connStr); try { myConnection.Open(); SqlCommand selectAllCmd = new SqlCommand(selectCommand, myConnection); SqlDataReader myDataReader = selectAllCmd.ExecuteReader(); while (myDataReader.Read()) { jd newrow = new jd(); newrow.JID = (int)myDataReader[0]; if (!myDataReader.IsDBNull(1)) { newrow.JName = (string)myDataReader[1]; } if (!myDataReader.IsDBNull(2)) { newrow.JDescription = (string)myDataReader[2]; } if (!myDataReader.IsDBNull(3)) { newrow.JWarrenty = (string)myDataReader[3]; } if (!myDataReader.IsDBNull(4)) { newrow.JHoursEstimated = (decimal)myDataReader[4]; } if (!myDataReader.IsDBNull(5)) { newrow.JHoursTook = (decimal)myDataReader[5]; } if (!myDataReader.IsDBNull(6)) { newrow.JPrice = (decimal)myDataReader[6]; } if (!myDataReader.IsDBNull(7)) { newrow.JSqaures = (decimal)myDataReader[7]; } if (!myDataReader.IsDBNull(8)) { newrow.JDate = (DateTime)myDataReader[8]; } JobCardRows.Add(newrow); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { myConnection.Close(); } }
//loads list with data void loadJobCardRows() { JobCardRows.Clear(); myConnection = new SqlConnection(connStr); try { myConnection.Open(); SqlCommand selectAllCmd = new SqlCommand(selectCommand, myConnection); SqlDataReader myDataReader = selectAllCmd.ExecuteReader(); while(myDataReader.Read()) { jd newrow = new jd(); newrow.JID = (int)myDataReader[0]; if(!myDataReader.IsDBNull(1)) newrow.JName = (string)myDataReader[1]; if(!myDataReader.IsDBNull(2)) newrow.JDescription = (string)myDataReader[2]; if (!myDataReader.IsDBNull(3)) newrow.JWarrenty = (string)myDataReader[3]; if (!myDataReader.IsDBNull(4)) newrow.JHoursEstimated = (decimal)myDataReader[4]; if (!myDataReader.IsDBNull(5)) newrow.JHoursTook = (decimal)myDataReader[5]; if (!myDataReader.IsDBNull(6)) newrow.JPrice = (decimal)myDataReader[6]; if (!myDataReader.IsDBNull(7)) newrow.JSqaures = (decimal)myDataReader[7]; if (!myDataReader.IsDBNull(8)) newrow.JDate= (DateTime)myDataReader[8]; JobCardRows.Add(newrow); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { myConnection.Close(); } }