一聚教程网:一个值得你收藏的教程网站

热门教程

存储过程执行select与insert同一个表sql语句

时间:2022-06-25 05:05:23 编辑:袖梨 来源:一聚教程网

存储过程执行select与insert同一个表sql语句
public void onedb_twoconnect()
        {
            using (transactionscope scope = new transactionscope())
            {

                mysql教程connection conn1 = new mysqlconnection("server=127.0.0.1;database=test;uid=root;pwd=123");
                conn1.open();

                mysqlcommand cmd1 = new mysqlcommand("select * from company", conn1);
                cmd1.executenonquery();

 

                mysqlconnection conn2 = new mysqlconnection("server=127.0.0.1;database=test;uid=root;pwd=123");
                conn2.open();


                mysqlcommand cmd3 = new mysqlcommand("insert into company(companyid, companyname, createtime, createuser) values(@companyid, @companyname, @createtime, @createuser)", conn2);
                cmd3.parameters.add("@companyid", guid.newguid());
                cmd3.parameters.add("@companyname", "testsss");
                cmd3.parameters.add("@createtime", datetime.now);
                cmd3.parameters.add("@createuser", "test");


                cmd3.executenonquery();


                scope.complete();
            }

        }

热门栏目