Example #1
0
        public static Task OpenAsync(this MySqlConnection conn)
        {
            var tcs = new TaskCompletionSource <int>();

            conn.InternalOpen(() => tcs.SetResult(0));
            return(tcs.Task);
        }
Example #2
0
        public static void Test1_Select()
        {
            ConnectionConfig config = new ConnectionConfig("root", "root");

            config.database = "test";
            MySqlConnection sqlConn = new MySqlConnection(config.host, config.user, config.password, config.database);

            sqlConn.UseConnectionPool = true;
            sqlConn.InternalOpen();
            string       sql     = "select * from ??t1 where ??c1 > ?n1 and ??c1 < ?n2";
            int          testN1  = 4510;
            int          testN2  = 4520;
            MySqlCommand command = new MySqlCommand(sql, sqlConn);

            command.Parameters.SetSqlPart("??t1", "saveimage");
            command.Parameters.SetSqlPart("??c1", "idsaveImage");
            command.Parameters.AddWithValue("?n1", testN1);
            command.Parameters.AddWithValue("?n2", testN2);
            var reader = command.ExecuteReader();
            int count  = 0;

            while (reader.Read())
            {
                Console.WriteLine("Id : " + reader.GetInt32(0));
                Console.WriteLine("Buffer size : " + reader.GetBuffer(1).Length);
                ++count;
                if (count >= 3)
                {
                    break;
                }
            }
            reader.Close();
        }
Example #3
0
        public static void Test1_Delete()
        {
            ConnectionConfig config = new ConnectionConfig("root", "root");

            config.database = "test";
            MySqlConnection sqlConn = new MySqlConnection(config.host, config.user, config.password, config.database);

            sqlConn.UseConnectionPool = true;
            sqlConn.InternalOpen();
            string       sql     = "select * from ??t1 where ??c1 > ?n1 and ??c1 < ?n2";
            int          testN1  = 4510;
            int          testN2  = 4520;
            MySqlCommand command = new MySqlCommand(sql, sqlConn);

            command.Parameters.SetSqlPart("??t1", "saveimage");
            command.Parameters.SetSqlPart("??c1", "idsaveImage");
            command.Parameters.AddWithValue("?n1", testN1);
            command.Parameters.AddWithValue("?n2", testN2);
        }
        public static void Test1_Insert()
        {
            //string filename = "TestMe.png";//216,362 bytes
            byte[] buffer = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            ConnectionConfig config = new ConnectionConfig("localhost", "root", "root");

            config.database = "test";
            MySqlConnection sqlConn = new MySqlConnection(config.host, config.user, config.password, config.database);

            sqlConn.UseConnectionPool = true;
            sqlConn.InternalOpen();
            string       sql     = "INSERT INTO ??t1 SET ??c2 = ?buffer1";
            MySqlCommand command = new MySqlCommand(sql, sqlConn);

            command.Parameters.SetSqlPart("??t1", "saveimage");
            command.Parameters.SetSqlPart("??c2", "saveImagecol");
            command.Parameters.AddWithValue("?buffer1", buffer);
            command.ExecuteNonQuery();
            sqlConn.InternalClose();
        }
Example #5
0
        public static void Test1_Insert()
        {
            string filename = "TestMe.png";//216,362 bytes

            //filename = "Colorful.jpg";//885,264 bytes
            //filename = "TestJpg.jpg";//2,066 bytes
            byte[]           buffer = File.ReadAllBytes("D:\\[]Photo\\" + filename);
            ConnectionConfig config = new ConnectionConfig("root", "root");

            config.database = "test";
            MySqlConnection sqlConn = new MySqlConnection(config.host, config.user, config.password, config.database);

            sqlConn.UseConnectionPool = true;
            sqlConn.InternalOpen();
            string       sql     = "INSERT INTO ??t1 SET ??c2 = ?buffer1";
            MySqlCommand command = new MySqlCommand(sql, sqlConn);

            command.Parameters.SetSqlPart("??t1", "saveimage");
            command.Parameters.SetSqlPart("??c2", "saveImagecol");
            command.Parameters.AddWithValue("?buffer1", buffer);
            command.ExecuteNonQuery();
        }
 public static void Test1_Delete()
 {
     ConnectionConfig config = new ConnectionConfig("root", "root");
     config.database = "test";
     MySqlConnection sqlConn = new MySqlConnection(config.host, config.user, config.password, config.database);
     sqlConn.UseConnectionPool = true;
     sqlConn.InternalOpen();
     string sql = "select * from ??t1 where ??c1 > ?n1 and ??c1 < ?n2";
     int testN1 = 4510;
     int testN2 = 4520;
     MySqlCommand command = new MySqlCommand(sql, sqlConn);
     command.Parameters.SetSqlPart("??t1", "saveimage");
     command.Parameters.SetSqlPart("??c1", "idsaveImage");
     command.Parameters.AddWithValue("?n1", testN1);
     command.Parameters.AddWithValue("?n2", testN2);
 }
 public static void Test1_Insert()
 {
     string filename = "TestMe.png";//216,362 bytes
     //filename = "Colorful.jpg";//885,264 bytes
     //filename = "TestJpg.jpg";//2,066 bytes
     byte[] buffer = File.ReadAllBytes("D:\\[]Photo\\" + filename);
     ConnectionConfig config = new ConnectionConfig("root", "root");
     config.database = "test";
     MySqlConnection sqlConn = new MySqlConnection(config.host, config.user, config.password, config.database);
     sqlConn.UseConnectionPool = true;
     sqlConn.InternalOpen();
     string sql = "INSERT INTO ??t1 SET ??c2 = ?buffer1";
     MySqlCommand command = new MySqlCommand(sql, sqlConn);
     command.Parameters.SetSqlPart("??t1", "saveimage");
     command.Parameters.SetSqlPart("??c2", "saveImagecol");
     command.Parameters.AddWithValue("?buffer1", buffer);
     command.ExecuteNonQuery();
 }
 public static void Test1_Select()
 {
     ConnectionConfig config = new ConnectionConfig("root", "root");
     config.database = "test";
     MySqlConnection sqlConn = new MySqlConnection(config.host, config.user, config.password, config.database);
     sqlConn.UseConnectionPool = true;
     sqlConn.InternalOpen();
     string sql = "select * from ??t1 where ??c1 > ?n1 and ??c1 < ?n2";
     int testN1 = 4510;
     int testN2 = 4520;
     MySqlCommand command = new MySqlCommand(sql, sqlConn);
     command.Parameters.SetSqlPart("??t1", "saveimage");
     command.Parameters.SetSqlPart("??c1", "idsaveImage");
     command.Parameters.AddWithValue("?n1", testN1);
     command.Parameters.AddWithValue("?n2", testN2);
     var reader = command.ExecuteReader();
     int count = 0;
     while (reader.Read())
     {
         Console.WriteLine("Id : " + reader.GetInt32(0));
         Console.WriteLine("Buffer size : " + reader.GetBuffer(1).Length);
         ++count;
         if (count >= 3)
         {
             break;
         }
     }
     reader.Close();
 }