Exemple #1
0
 private void sendLocal() //send data to localdatabase
 {
     if (databasecmd.connection.State == ConnectionState.Closed)
     {
         databasecmd.connectDB();
     }
     try
     {
         int    i        = 0;
         string StrQuery = @"INSERT INTO checkpoint (epc,time,ant_id,point) VALUES ("
                           + "\"" + dataGridView1.Rows[i].Cells["epc"].Value + "\",\""
                           + dataGridView1.Rows[i].Cells["time"].Value + "\","
                           + dataGridView1.Rows[i].Cells["ant"].Value + ",\"" + checkP + "\"" + ");";
         databasecmd.cmd.CommandText = StrQuery;
         Console.WriteLine(StrQuery);
         databasecmd.cmd.ExecuteNonQuery();
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (databasecmd.connection.State == ConnectionState.Open)
         {
             databasecmd.connection.Close();
         }
     }
 }
Exemple #2
0
        private bool validate_login(string user, string pass)
        {
            databasecmd = new ConnectDatabase();
            databasecmd.connectDB();
            databasecmd.cmd.CommandText = "Select username , password from login where username=@user and password=@pass";
            databasecmd.cmd.Parameters.AddWithValue("@user", user);
            databasecmd.cmd.Parameters.AddWithValue("@pass", pass);
            databasecmd.cmd.Connection = databasecmd.connection;
            MySqlDataReader login = databasecmd.cmd.ExecuteReader();

            if (login.Read())
            {
                databasecmd.connection.Close();
                return(true);
            }
            else
            {
                databasecmd.connection.Close();
                return(false);
            }
        }