protected void Page_Load(object sender, EventArgs e)
{
OracleDataAdapter da = reDS();
//da.Dispose();
Response.Write(da.SelectCommand.CommandText);
}
private OracleDataAdapter reDS()
{
string a = ConfigurationManager.AppSettings["CONN"];
using (OracleDataAdapter da = new OracleDataAdapter("select * FROM AAA WHERE ROWNUM<5", a))
{
return da;
}
}
这里using 起到了销毁对象的作用···但用dataset作实验时还是不行··· {
OracleDataAdapter da = reDS();
//da.Dispose();
Response.Write(da.SelectCommand.CommandText);
}
private OracleDataAdapter reDS()
{
string a = ConfigurationManager.AppSettings["CONN"];
using (OracleDataAdapter da = new OracleDataAdapter("select * FROM AAA WHERE ROWNUM<5", a))
{
return da;
}
}
protected void Page_Load(object sender, EventArgs e)
{
OracleCommand cmd = reCmd();
cmd.Dispose();
Response.Write(cmd.CommandText);
}
OracleCommand reCmd()
{
string a = ConfigurationManager.AppSettings["CONN"];
string b = "select * FROM AAA WHERE ROWNUM<5";
OracleConnection con = new OracleConnection(a);
using (OracleCommand cmd = new OracleCommand(b, con))
{
return cmd;
}
}
这里的cmd对象也被销毁了 , 但确还可以访问它的CommandText····奇怪的东西····
{
OracleCommand cmd = reCmd();
cmd.Dispose();
Response.Write(cmd.CommandText);
}
OracleCommand reCmd()
{
string a = ConfigurationManager.AppSettings["CONN"];
string b = "select * FROM AAA WHERE ROWNUM<5";
OracleConnection con = new OracleConnection(a);
using (OracleCommand cmd = new OracleCommand(b, con))
{
return cmd;
}
}