哪位有经过验证的、能真正解决并发的方案、代码?
在csdn找到的代码,经测试,并不能真正解决并发问题:
http://bbs.csdn.net/topics/300102785
public void ExeSqls(string theSql)
{
using (SqlCommand theCommand2 = new SqlCommand())
{
theConn.Open();
SqlTransaction trans = theConn.BeginTransaction(IsolationLevel.ReadCommitted);
try
{
theCommand2.Connection = theConn;
theCommand2.Transaction = trans;
theCommand2.CommandText = theSql;
theCommand2.ExecuteNonQuery();
trans.Commit();
}
catch (Exception ex)
{
trans.Rollback();
throw new ApplicationException(ex.Message);
}
finally
{
theConn.Close();
}
}
}
在csdn找到的代码,经测试,并不能真正解决并发问题:
http://bbs.csdn.net/topics/300102785
public void ExeSqls(string theSql)
{
using (SqlCommand theCommand2 = new SqlCommand())
{
theConn.Open();
SqlTransaction trans = theConn.BeginTransaction(IsolationLevel.ReadCommitted);
try
{
theCommand2.Connection = theConn;
theCommand2.Transaction = trans;
theCommand2.CommandText = theSql;
theCommand2.ExecuteNonQuery();
trans.Commit();
}
catch (Exception ex)
{
trans.Rollback();
throw new ApplicationException(ex.Message);
}
finally
{
theConn.Close();
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货