Windows Mobile 5 / SQL Mobile Record Counts
-
private void R1RecCount() { if (RAMDataSetUtil.DesignerUtil.IsRunTime()) { R1Count.Visible = true; conn = new SqlCeConnection("Data Source = \\My Documents\\RAM.sdf"); conn.Open(); SqlCeCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT COUNT ([StatusCode]) FROM R1Time"; SqlCeDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { count = count + 1; if (count >= 1) { //MessageBox.Show(rdr.GetValue(0).ToString()); //Eventually will ad button to this screen this.rAMDataSet.R1Time.AddR1TimeRow( rdr.GetValue(0).ToString(), rdr.GetValue(1).ToString(), rdr.GetValue(2).ToString(), rdr.GetValue(3).ToString(), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetValue(6).ToString(), rdr.GetValue(7).ToString()); } } } this.r1TimeTableAdapter.Fill(this.rAMDataSet.R1Time); conn.Close(); }
This doesn't seem to count? I also tried creating a new query in the Dataset, doing a count likeSELECT COUNT(1) AS R1 FROM R1Time
then calling it as the fill. Thanks for your help! Paul -
private void R1RecCount() { if (RAMDataSetUtil.DesignerUtil.IsRunTime()) { R1Count.Visible = true; conn = new SqlCeConnection("Data Source = \\My Documents\\RAM.sdf"); conn.Open(); SqlCeCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT COUNT ([StatusCode]) FROM R1Time"; SqlCeDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { count = count + 1; if (count >= 1) { //MessageBox.Show(rdr.GetValue(0).ToString()); //Eventually will ad button to this screen this.rAMDataSet.R1Time.AddR1TimeRow( rdr.GetValue(0).ToString(), rdr.GetValue(1).ToString(), rdr.GetValue(2).ToString(), rdr.GetValue(3).ToString(), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetValue(6).ToString(), rdr.GetValue(7).ToString()); } } } this.r1TimeTableAdapter.Fill(this.rAMDataSet.R1Time); conn.Close(); }
This doesn't seem to count? I also tried creating a new query in the Dataset, doing a count likeSELECT COUNT(1) AS R1 FROM R1Time
then calling it as the fill. Thanks for your help! PaulWell I know I didn't do it the correct way.. However it does work...
private void R1RecCount() { R1Count.Visible = false; conn = new SqlCeConnection("Data Source = \\My Documents\\RAM.sdf"); conn.Open(); SqlCeCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM R1Time"; SqlCeDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { countr1 = countr1 + 1; if (countr1 >= 1) { //MessageBox.Show(rdr.GetValue(0).ToString()); //Eventually will ad button to this screen this.rAMDataSet.R1Time.AddR1TimeRow( rdr.GetValue(0).ToString(), rdr.GetValue(1).ToString(), rdr.GetValue(2).ToString(), rdr.GetValue(3).ToString(), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetValue(6).ToString(), rdr.GetValue(7).ToString()); } } R1c.Text = countr1.ToString(); R1c.Enabled = false; this.r1TimeTableAdapter.Fill(this.rAMDataSet.R1Time); conn.Close(); }
Computer Programmer Web/Mobile .NET