我发现在写数据操作类的时候,connection的对象不是总在执行前打开的,例如:
//第一种情况
SqlConnection conn = new Connection(conStr);
SqlCommand comm = new SqlCommand(sql,comm);
conn.open();
comm.ExecuteNonQuery();
//第二种情况
SqlConnection conn = new Connection(conStr);
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
SqlTransaction trans = conn.BeginTransaction();
comm.Transaction = trans;
蝴蝶刀刀
蝴蝶不菲
相关分类