示例#1
0
 /// <summary>
 /// 执行SQL语句,返回影响的记录数
 /// </summary>
 /// <param name="SQLString">SQL语句</param>
 /// <returns>影响的记录数</returns>
 public static int ExecuteSqlByPomeloDataMyCat(string SQLString)
 {
     using (var conn = new MyCatConnection(ConfigurationManager.AppSettings["PersonCenterConnectionString"]))
     {
         conn.Open();
         using (var cmd = new MyCatCommand(SQLString, conn))
         {
             return(cmd.ExecuteNonQuery());
         }
     }
 }
示例#2
0
        static void dddd222()
        {
            try
            {
                for (var i = 0; i < 1; i++)
                {
                    using (MyCatConnection conn = new MyCatConnection("server=localhost;port=3306;database=db1;uid=root;pwd=;CharSet=utf8;pooling=true;Allow User Variables=True"))
                    {
                        //conn("INSERT INTO `test` (`name`) VALUES ( '" + System.DateTime.Now.ToString() + "')");


                        conn.Open();

                        var cmd = new MyCatCommand("INSERT INTO `test` (`name`) VALUES ( '" + System.DateTime.Now.ToString() + "')", conn);

                        cmd.ExecuteNonQuery();
                    }

                    //using (var conn = new MyCatConnection("server=localhost;port=8066;database=TESTDB;uid=root;pwd=123456;CharSet=utf8;pooling=true;Connection Timeout=10"))
                    //{
                    //	conn.Open();

                    //	var command = new MyCatCommand("INSERT INTO `test` (`name`) VALUES ( '" + System.DateTime.Now.ToString() + "')", conn);
                    //	//command.ExecuteReader("select  *  from `test`");
                    //	conn.Query("select  name  from `test`");

                    //	command.ExecuteNonQuery();

                    //}
                    //if (conn == null)
                    //	conn = new MyCatConnection("server=localhost;port=8066;database=TESTDB;uid=root;pwd=123456;CharSet=utf8;pooling=true;Connection Timeout=10");

                    //	var conn = new MyCatConnection("server=localhost;port=8066;database=TESTDB;uid=root;pwd=123456;CharSet=utf8;pooling=true;Connection Timeout=10");
                    //	conn.Execute("INSERT INTO `test` (`name`) VALUES ( '" + System.DateTime.Now.ToString() + "')");


                    //	conn.Query("select  name  from `test`");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());

                Write(ex.ToString());
            }



            //for (int i = 0; i < 1; i++)

            //{
            //	//
            //	var conn = new MyCatConnection("server=localhost;port=8066;database=TESTDB;uid=root;pwd=123456;CharSet=utf8;pooling=true;Connection Timeout=10");

            //		conn.Open();

            //	var cmd = new MyCatCommand("INSERT INTO `test` (`name`) VALUES ( '" + System.DateTime.Now.ToString() + "')", conn);

            //		cmd.ExecuteNonQuery();


            //		conn.Close();



            //	//using (var conn = new MySqlConnection("server=localhost;port=3306;database=acdb;uid=root;pwd=123456;CharSet=utf8;pooling=true"))
            //	//{
            //	//	//	conn.Execute("INSERT INTO `test` (`name`) VALUES ( '" + System.DateTime.Now.ToString() + "')");
            //	//	conn.Execute("INSERT INTO `test` (`taskid`,`taskid2`,`dtime`) VALUES ('" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fffffff") + "'," + 0 + ", '" + System.DateTime.Now.ToString() + "')");



            //}


            //}
        }