Quantcast
Channel: Project Online General Questions and Answers forum
Viewing all articles
Browse latest Browse all 3067

SQLITE update statement

$
0
0

I have a SQLITE data base my saving to the data base works correctly but when I update it does nothing no errors.

I'm not sure what to do next.

#region Save

        private void btn_Save_Click(object sender, EventArgs e)
        {
            var data = new Data();
            data.AttendanceData(
                dateTimePicker1.Value, tb_Leader_Present.Text, tb_Leader_Online.Text,
                tb_Roll.Text, tb_Required_Roll.Text,
                tb_Sick.Text, tb_Sick_comm.Text,
                tb_Vac.Text, tb_Vac_comm.Text,
                tb_Personal.Text, tb_Personal_comm.Text,
                tb_Qday.Text, tb_Q_comm.Text,
                tb_Late.Text, tb_Late_comm.Text,
                tb_Early.Text, tb_Early_comm.Text,
                tb_LOA.Text, tb_LOA_comm.Text,
                tb_Long_LOA.Text, tb_Long_comm.Text,
                tb_Offsite.Text, tb_Offsite_comm.Text,
                tb_Other.Text, tb_Other_comm.Text,
                
            tb_Over_Under.Text = (double.Parse(tb_Roll.Text) - double.Parse(tb_Required_Roll.Text)).ToString(),
            tb_Total.Text = (double.Parse(tb_Sick.Text) + double.Parse(tb_Vac.Text) +
           (double.Parse(tb_Personal.Text) + double.Parse(tb_Qday.Text) +
           (double.Parse(tb_Late.Text) + double.Parse(tb_Early.Text) +
           (double.Parse(tb_LOA.Text) + double.Parse(tb_Long_LOA.Text) +
           (double.Parse(tb_Offsite.Text)+ double.Parse(tb_Other.Text)))))).ToString());



            MessageBox.Show("Saved to DataBase");

        }

        #endregion

        private void btn_Update_Click(object sender, EventArgs e)

        {
            var data = new Data();

                string query = "Update Attendance set Leader_Present='" + this.tb_Leader_Present.Text + "',Leader_Online='" + this.tb_Leader_Online +"',Roll='" + this.tb_Roll.Text+"',Required_Roll='" + this.tb_Required_Roll.Text + "',Sick='" + this.tb_Sick.Text + "',Sick_comm='" + this.tb_Sick_comm.Text +"' , Vac = '" + this.tb_Vac.Text +"', Vac_comm = '" + this.tb_Vac_comm.Text + "', Personal='" + this.tb_Personal.Text + "',Personal_comm='" + this.tb_Personal_comm.Text +"',Qdat='" + this.tb_Qday.Text + "',_Q_comm='" + this.tb_Q_comm.Text + "',Late='" + this.tb_Late.Text + "',Late_comm='" + this.tb_Late_comm.Text +"',Early='" + this.tb_Early.Text + "',Early_comm='" + this.tb_Early_comm.Text + "',LOA='" + this.tb_LOA.Text + "',LOA_comm='" + this.tb_LOA_comm.Text +"',long_LOA='" + this.tb_Long_LOA.Text + "',Long_comm='" + this.tb_Long_comm.Text + "',Offsite='" + this.tb_Offsite.Text + "',Offsite_comm='" + this.tb_Offsite_comm.Text +"',Other='" + this.tb_Other.Text + "',Other_comm='" + this.tb_Other_comm.Text + "',Total='" + this.tb_Total.Text + "',Over_Under='" + this.tb_Over_Under.Text + "' where Leader_Present='" + this.tb_Leader_Present.Text +"'";
            }
        }

    }

Create Table

  #region Create Attendance Table

        private void createAttendanceTable()  /// Attendance
        {
            try
            {
                getConnection();
                using (SQLiteConnection con = new SQLiteConnection(connection))
                {
                    con.Open();
                    SQLiteCommand cmd = new SQLiteCommand();

                    string query = @"CREATE TABLE Attendance ( Production_Date DATETIME PRIMARY KEY,
                                     Leader_Present Text(25), Leader_Online Text(25), Roll Text(25),
                                     Required_Roll Text(25), Sick Text(10), Sick_comm Text(50),
                                     Vac Text(10), Vac_comm Text(50), Personal Text(10), Personal_comm Text(50),
                                     Qday Text(10), Q_comm Text(50), Late Text(10), Late_comm Text(50),
                                     Early Text(10), Early_comm Text(50), LOA Text(10), LOA_comm Text(50),
                                     Long_LOA Text(10), Long_comm Text(50), Offsite Text(10), Offsite_comm Text(50),
                                     Other Text(10), Other_comm Text(50), Total Text(10), Over_Under Text(10))";
                    cmd.CommandText = query;
                    cmd.Connection = con;
                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }


Booney440


Viewing all articles
Browse latest Browse all 3067

Latest Images

Trending Articles





Latest Images