SQL in() 和base.Dispose(disposing)的问题求助。。。
public DataSet get_doc(string cuid,int doctype)
{
SqlParameter[] pars ={
MakeInParam("@cuid",SqlDbType.NVarChar,200,cuid),
MakeInParam("@doctype",SqlDbType.TinyInt,4,doctype),
};
return RunProc("select a.*, b.flow_name, c.node_name, c.node_type_id, c.node_order_id, c.node_next_id from t_doc a, t_flow b, t_node c where a.df = 0 and a.cu in (@cuid) and a.st in ( 0,1,4 ) and a.doc_type = @doctype and a.flow_id *= b.flow_id and a.node_id *= c.node_id order by a.doc_id desc", pars, "t_doc123");
}
public DataSet RunProc(string procN, SqlParameter[] prams, string tbN)
{
SqlDataAdapter dap = CreateDataAdaper(procN, prams);
DataSet ds = new DataSet();
dap.Fill(ds, tbN);
this.Close();
return ds;
}
private SqlDataAdapter CreateDataAdaper(string procN, SqlParameter[] prams)
{
this.Open();
SqlDataAdapter dap = new SqlDataAdapter(procN,con);
dap.SelectCommand.CommandType = CommandType.Text;
if (prams != null)
{
foreach (SqlParameter parameter in prams)
dap.SelectCommand.Parameters.Add(parameter);
}
dap.SelectCommand.Parameters.Add(new SqlParameter("ReturnValue", SqlDbType.Int, 4,
ParameterDirection.ReturnValue, false, 0, 0,
string.Empty, DataRowVersion.Default, null));
return dap;
}
问题出在这个语句:
select a.*, b.flow_name, c.node_name, c.node_type_id, c.node_order_id, c.node_next_id from t_doc a, t_flow b, t_node c where a.df = 0 and a.cu in (@cuid) and a.st in ( 0,1,4 ) and a.doc_type = @doctype and a.flow_id *= b.flow_id and a.node_id *= c.node_id order by a.doc_id desc
的in (@cuid)
程序会跳到:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
如果不传参数,直接in(1,2,3,4)这样。程序就没问题了。
请问有为什么和怎么解决呢?
...全文
相关推荐
asp.net sqlconnection con.close和con.dispose区别
con.close是用来关闭和数据库的连接,相对于open
类中可调用的方法总结
数据库可调用的一些方法,自己总结所的,有返回datatable类型,执行sql语句等等
C#中创建SQl
共享 在编写数据库应用程序的时候,我们可以通过SQL语句来动态创建、修改数据库以及其中的对象
NoIOCFramework(009控制台动态实例UnitOfWork-Dispose调用模式,MiniProfiler10组1000次读写性能监视)
框架、模式和依赖注入详解,使用常规开发思想和技术实现基于.NET Framework框架的第9个工程代码。
ASP.NET WebForms Page生命周期与ViewState深度解析
ASP.NET WebForms是一种基于服务端控件、事件驱动和状态保持的传统Web开发模型。其核心在于Page生命周期的严格时序控制、ViewState的状态序列化机制,以及PostBack触发的服务器端事件路由原理。理解Init/Load/PreRender等阶段的执行边界,可精准定位数据丢失、事件不触发、控件状态异常等高频问题;掌握ViewState的差异存储本质与粒度化启停策略,能有效规避性能瓶颈与安全风险。本文聚焦Page生命周期、ViewState、PostBack三大技术支柱,结合真实政企系统


