c#conn.Open();using (SqlDataReader reader = cmd.ExecuteReader()){ while (reader.Read()) { datalist.Add(reader.GetValue("Id").ToString()); StatusArea.Text = "ID Added"; datalist.Add(reader.GetValue("c_location").ToString()); StatusArea.Text = "C Loc Added"; datalist.Add(reader.GetValue("job_date").ToString()); StatusArea.Text = "Date Added"; datalist.Add(reader.GetValue("l_location").ToString()); StatusArea.Text = "Table Made"; }}
C#string connetionString = @"Data Source= " + ServerName + ";Initial Catalog= " + Database + ";User ID=" + Username + ";Password= " + Password + ";";using (SqlConnection conn = new SqlConnection(connetionString)){ string lbcompjob = ("SELECT * FROM " + Table + " WHERE [cancled] = 1"); SqlCommand cmd = new SqlCommand(lbcompjob, conn); { try { conn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { string can = dr[0].ToString(); if (can == "1") { if (dr.Length == 0 || dataview.Rows.Count == 0 || dataview.Rows[0].Cells.Count < 26) { // The grid doesn't have enough rows or cells to access data in Row 1 Cell 26 Console.WriteLine("Cell 26 doesn't exist!"); return; } } } } } catch (Exception ex) { } }}
c# conn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { string can = dr[0].ToString(); if (can == "1") { if (dr.Length == 0 || dataview.Rows.Count == 0 || dataview.Rows[0].Cells.Count < 26) { // The grid doesn't have enough rows or cells to access data in Row 1 Cell 26 Console.WriteLine("Cell 26 doesn't exist!"); return; } // Not sure what 'dr' is string can = dr[0].ToString(); if (can == "1" && dataview.Rows[0].Cells[26].Value as int? == 1) { dataview.RowBackground = Brushes.LightPink; } } } }
cs workarea.Content = null
.Close();