dbconn的定义略
try
{
dbconn.Open();
foreach(GridViewRow row in GridView.Rows)
{
string userID = row.Cells[0].Text;
string userName = row.Cells[1].Text;
string sqlStr = "INSERT INTO user(userid, userName) VALUES('" + userID + "', '" + userName + "');
DbCommand dbCommand = db.GetSqlStringCommand(sqlStr);
db.ExecuteNonQuery(dbCommand);
}
dbtran.Commit();
}
catch
{
dbtran.Rollback();
}
finally
{
dbconn.Close();
}
C#中事务
最新推荐文章于 2025-12-02 19:45:00 发布
154

被折叠的 条评论
为什么被折叠?



