access事务插入多条记录
来源:互联网 发布:口袋妖怪图鉴软件 编辑:程序博客网 时间:2024/06/06 09:55
protected void Button1_Click(object sender, EventArgs e)
{
/*=============测试通过===============*/
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data
Source=C:/Inetpub/wwwroot/DotNetArticle/App_Data/DotNetArticle.mdb");
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
cmd.Transaction = con.BeginTransaction();
try
{
string sql1 = "insert into teaminfo (num,username,isplay) values(1,'a',1)";
string sql2 = "insert into teaminfo (num,username,isplay) values(2,'b',1)";
string sql3 = "insert into teaminfo (num,username,isplay) values(3,'c',1)";
string[] SQLStringList = { sql1, sql2, sql3 };
for (int n = 0; n < SQLStringList.Length; n++)
{
string strsql = SQLStringList[n].ToString();
if (strsql.Trim().Length > 1)
{
cmd.CommandText = strsql;
cmd.ExecuteNonQuery();
}
}
cmd.Transaction.Commit(); //提交事务
Response.Write("OK");
}
catch (Exception)
{
cmd.Transaction.Rollback();
}
finally
{
con.Close();
}
}
{
/*=============测试通过===============*/
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data
Source=C:/Inetpub/wwwroot/DotNetArticle/App_Data/DotNetArticle.mdb");
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
cmd.Transaction = con.BeginTransaction();
try
{
string sql1 = "insert into teaminfo (num,username,isplay) values(1,'a',1)";
string sql2 = "insert into teaminfo (num,username,isplay) values(2,'b',1)";
string sql3 = "insert into teaminfo (num,username,isplay) values(3,'c',1)";
string[] SQLStringList = { sql1, sql2, sql3 };
for (int n = 0; n < SQLStringList.Length; n++)
{
string strsql = SQLStringList[n].ToString();
if (strsql.Trim().Length > 1)
{
cmd.CommandText = strsql;
cmd.ExecuteNonQuery();
}
}
cmd.Transaction.Commit(); //提交事务
Response.Write("OK");
}
catch (Exception)
{
cmd.Transaction.Rollback();
}
finally
{
con.Close();
}
}
- access事务插入多条记录
- access事务插入多条记录
- 插入多条记录事务:避免拼串
- 一次插入多条记录
- 一次插入多条记录
- 一次性插入多条记录
- mysql插入多条记录
- SQL 插入多条记录
- MySQL插入多条记录
- mybatis插入多条记录
- php插入多条记录
- ACCESS 一次性插入多条数据
- mysql 快速插入(insert)多条记录
- 向表中插入多条记录
- 一次插入多条记录 [mysql]
- SQL 一次插入多条记录 例句
- Oracle 插入多条记录的sql
- oracle同时插入多条记录
- 使用JS禁用浏览器后退按钮
- 解决Windows下依赖问题的利器——Dependency Walker
- Designing Integrated Solutions - Windows Azure Libraries for .NET FAQ
- Designing Integrated Solutions-Using Simple Web Token (SWT) with WIF
- linux网络编程系列之connect函数详解
- access事务插入多条记录
- 首页 > Ubuntu 命令 > linux 查看文件内容
- git常用操作
- VC++6.0快捷键大全
- cocos2d-x 输出debug信息
- Designing Integrated Solutions-Claims-Based Single Sign-On for the Web and Windows Azure
- Qt styleSheet 设置
- linux文件查看命令实例
- Android去哪儿客户端(1)