当前位置:编程学习 > C#/ASP.NET >>

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

存储过程执行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();
            }

        }

补充:asp.net教程,C语言
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,