public void Pulse() { string istring = @"INSERT INTO tblUsers (username, distance, pulsetime) VALUES ('" + Environment.UserName + "'," + this.labSeshDistance.Text + ",#" + DateTime.Now + "#);"; //@"INSERT into tblUsers (username, distance) VALUES ('" + Environment.UserName + "',0);"; conn.Open(); OleDbCommand cmd = new OleDbCommand(istring, conn); cmd.ExecuteNonQuery(); conn.Close(); this.labSeshDistance.Text="0"; }
public void RefreshValues() { conn.Open(); adap = new OleDbDataAdapter("SELECT SUM(distance) AS tdistance FROM tblUsers WHERE username='" + Environment.UserName + "'",conn); adap.Fill(datat);
DataRow myline = datat.Rows[0]; this.labPrevDistance.Text=myline["tdistance"].ToString();
adap.Dispose(); datat.Dispose(); conn.Close(); }
At the start of the class I have these 3 lines
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=L:\BDSU\Archive\Personal - TO BE SORTED\Scott Thurlow\InTheDistance.mdb; User Id=admin; Password=;"); OleDbDataAdapter adap = new OleDbDataAdapter(); DataTable datat = new DataTable();