数据库事务怎么结束?
我用VS2010做一个Flash报表,想把数据库里查到的表放到一个数组中,在转化的过程中总是提示 ‘SET TRANSACTION READ ONLY’必须是事务执行的第一句,在网上查了下,大体就是说有没结束的sql语句之类,还有提到commit的,但是不知道具体怎么操作,望懂的朋友指点一二,本人菜鸟,见笑啦~ 出错代码
public static DataTable ReturnDataTable(string sql, OracleParameter[] op)
{
OracleConnection conn = new OracleConnection(ConnectionString);
DataTable dt = new DataTable();
try
{
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
conn.Close();
conn.Open();
cmd.Transaction = conn.BeginTransaction();
= "SET TRANSACTION READ ONLY";
OracleDataReader reader = cmd.ExecuteReader();//到此跳转出错
reader.Close();
= sql;
cmd.Parameters.AddRange(op);
OracleDataAdapter ad = new OracleDataAdapter(cmd);
ad.Fill(dt);
conn.Close();
}
catch (Exception ex)
{
conn.Close();
throw new Exception(ex.Message);
}
return dt;
}