Ejemplo n.º 1
0
        private static void QueryAsync(Statment statement)
        {
            MySqlConnection c = new MySqlConnection(strConnection);

            c.Open();
            MySqlCommand cmd = c.CreateCommand();

            cmd.CommandText = statement.query;
            foreach (KeyValuePair <string, object> entry in statement.parameters)
            {
                cmd.Parameters.AddWithValue(entry.Key, entry.Value);
            }
            cmd.Prepare();
            cmd.BeginExecuteNonQuery(new AsyncCallback(QueryAsyncCallback), new QueryObject <bool>(null, cmd));
        }
Ejemplo n.º 2
0
 private static void Query(Statment statement)
 {
     using (MySqlConnection c = new MySqlConnection(strConnection))
     {
         c.Open();
         using (MySqlCommand cmd = c.CreateCommand())
         {
             cmd.CommandText = statement.query;
             foreach (KeyValuePair <string, object> entry in statement.parameters)
             {
                 cmd.Parameters.AddWithValue(entry.Key, entry.Value);
             }
             cmd.Prepare();
             cmd.ExecuteNonQuery();
         }
     }
 }
Ejemplo n.º 3
0
        private static DataTable Read(Statment statement)
        {
            DataTable retVal = new DataTable();

            using (MySqlConnection c = new MySqlConnection(strConnection))
            {
                c.Open();
                using (MySqlCommand cmd = c.CreateCommand())
                {
                    cmd.CommandText = statement.query;
                    foreach (KeyValuePair <string, object> entry in statement.parameters)
                    {
                        cmd.Parameters.AddWithValue(entry.Key, entry.Value);
                    }
                    cmd.Prepare();
                    retVal.Load(cmd.ExecuteReader());
                }
            }
            return(retVal);
        }