引用未被删除重新访问 [英] reference not removed revisited

查看:73
本文介绍了引用未被删除重新访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我再次就下一个问题请求帮助,之前的问题没有给出

解决方案。


这条消息底部的方法留下了对somethig的引用,因为我可以告诉_sqladapter变量。正如你所看到的那样,我使用

''使用''语句,所以适配器和连接应该整齐地处理掉。

但是它不会!

我会祈祷解决方案。

谢谢

Frank

公共DataTable lees()

{

string ConnectString =" Server = localhost;数据库= AA;用户

id = uniserver;密码= aa;连接超时= 100;" ;;

DataSet _DataSet = new DataSet();

string StoredProcedure =" S_aa";

using(SqlConnection _SqlConnection = new SqlConnection(ConnectString))

{

using(SqlDataAdapter _SqlDataAdapter = new

SqlDataAdapter(StoredProcedure,_SqlConnection))

{

试试

{

_SqlDataAdapter .SelectCommand.CommandType = CommandT ype.StoredProcedure;

_SqlDataAdapter.Fill(_DataSet,StoredProcedure);

_SqlDataAdapter.SelectCommand = null;

}

catch(SqlException e)

{

Console.WriteLine(StoredProcedure + e.Message + e.Stac kTrace);

}

}

}

返回_DataSet.Tables [0];

}

Hello,
I again ask for help on the next problem, a previous question did not give a
solution.

The method at the bottom of this message leaves a reference to somethig, as
far as I can tell to the _sqladapter variable. As you can see I use the
''using'' statement so the adapter and the connection should be neatly
disposed of.
But it doesn''t!
I will be praying for a solution.
Thanks
Frank
public DataTable lees()
{
string ConnectString="Server= localhost; database=aa; User
id=uniserver;password=aa;Connect Timeout=100;";
DataSet _DataSet= new DataSet();
string StoredProcedure="S_aa";
using (SqlConnection _SqlConnection= new SqlConnection(ConnectString))
{
using (SqlDataAdapter _SqlDataAdapter = new
SqlDataAdapter(StoredProcedure,_SqlConnection))
{
try
{
_SqlDataAdapter.SelectCommand.CommandType=CommandT ype.StoredProcedure;
_SqlDataAdapter.Fill(_DataSet,StoredProcedure);
_SqlDataAdapter.SelectCommand=null;
}
catch (SqlException e)
{
Console.WriteLine(StoredProcedure+e.Message+e.Stac kTrace);
}
}
}
return _DataSet.Tables[0];
}

推荐答案

HI,


你怎么知道的?


还要记住GC,不是确定性的可以肯定的是,

将调用Dispose方法(使用原因)


现在,这样做。从SqlDataAdapter继承并覆盖Dispose,然后你就会看到
何时被调用。

IIRC处理调用关闭,所以如果按预期调用它就连接

已关闭且物体已准备好成为GC。


干杯,


-

Ignacio Machin,

ignacio.machin AT dot.state.fl.us

佛罗里达州交通局


弗兰克 < FR *** @ frank.com>在消息中写道

news:42 *********************** @ news.xs4all.nl ...


How do you know it?

Also remember that the GC is not deterministic, all you can assure is that
the Dispose method will be called ( cause of the using )

Now, do this. inherit from SqlDataAdapter and override Dispose , then you
will see when it''s called.
IIRC Dispose call Close , so if it''s called as expected the connection is
closed and the objects are ready to be GC.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:42***********************@news.xs4all.nl...
你好,
我再次就下一个问题请求帮助,前一个问题没有给出解决方案。

此消息底部的方法离开了对于someSig的引用,
据我所知告诉_sqladapter变量。如你所见,我使用了
''using''声明,因此适配器和连接应该整齐地处理掉。
但它不会!
我会祈求解决方案。
谢谢
$

公共DataTable lees()
{
字符串ConnectString =" Server = localhost;数据库= AA;用户
id = uniserver;密码= aa;连接超时= 100;" ;;
DataSet _DataSet = new DataSet();
string StoredProcedure =" S_aa";
using (SqlConnection _SqlConnection = new SqlConnection(ConnectString))
{
使用(SqlDataAdapter _SqlDataAdapter = new
SqlDataAdapter(StoredProcedure,_SqlConnection))
{
尝试
{

_SqlDataAdapter.SelectCommand.CommandType = CommandT ype.StoredProcedure;
_SqlDataAdapter.Fill(_DataSet,StoredProcedure);
_SqlDataAdapter.SelectCommand = null;
}
catch(SqlException e)
{
Console.WriteLine(StoredProcedure + e.Message + e.Stac kTrace);
}
}
} return _DataSet.Tables [0];
}
Hello,
I again ask for help on the next problem, a previous question did not give
a solution.

The method at the bottom of this message leaves a reference to somethig,
as far as I can tell to the _sqladapter variable. As you can see I use the
''using'' statement so the adapter and the connection should be neatly
disposed of.
But it doesn''t!
I will be praying for a solution.
Thanks
Frank
public DataTable lees()
{
string ConnectString="Server= localhost; database=aa; User
id=uniserver;password=aa;Connect Timeout=100;";
DataSet _DataSet= new DataSet();
string StoredProcedure="S_aa";
using (SqlConnection _SqlConnection= new SqlConnection(ConnectString))
{
using (SqlDataAdapter _SqlDataAdapter = new
SqlDataAdapter(StoredProcedure,_SqlConnection))
{
try
{

_SqlDataAdapter.SelectCommand.CommandType=CommandT ype.StoredProcedure;
_SqlDataAdapter.Fill(_DataSet,StoredProcedure);
_SqlDataAdapter.SelectCommand=null;
}
catch (SqlException e)
{
Console.WriteLine(StoredProcedure+e.Message+e.Stac kTrace);
}
}
}
return _DataSet.Tables[0];
}



Ignacio,


我用< a rel =nofollowhref =http://www.scitech.se/memprofiler/Default.htmtarget =_ blank> http://www.scitech.se/memprofiler/De fault.htm 查看refs。这是

弱推理。

我会用遗产尝试你的建议。

Frank

Ignacio Machin(.NET / C#MVP)" < ignacio.machin AT dot.state.fl.us>

schreef在bericht新闻:ud ************** @ TK2MSFTNGP14.phx.gbl .. 。
Ignacio,

I use http://www.scitech.se/memprofiler/Default.htm to see the refs. It''s a
weakreference.
I''ll try your suggestion with the inherit.
Frank
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:ud**************@TK2MSFTNGP14.phx.gbl...
HI,

你怎么知道呢?

还要记住,GC不是确定性的,所有你可以保证的是
现在,执行此操作。从SqlDataAdapter继承并覆盖Dispose,然后你会看到它被调用的时间。
IIRC处理调用关闭,所以如果按预期调用它,则关闭连接并且对象已准备好成为GC。

干杯,

- << Ignacio Machin,
ignacio.machin at dot.state.fl.us <佛罗里达州交通局

弗兰克 < FR *** @ frank.com>在消息中写道
新闻:42 *********************** @ news.xs4all.nl ...


How do you know it?

Also remember that the GC is not deterministic, all you can assure is that
the Dispose method will be called ( cause of the using )

Now, do this. inherit from SqlDataAdapter and override Dispose , then you
will see when it''s called.
IIRC Dispose call Close , so if it''s called as expected the connection is
closed and the objects are ready to be GC.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:42***********************@news.xs4all.nl...
您好,
我再次就下一个问题请求帮助,之前的问题没有给出解决方案。

此消息底部的方法留下了对somethig的引用,据我所知,_sqladapter变量。正如你所看到的那样,我使用''using''声明,所以适配器和连接应该整齐地处理掉。
但它不会!
我会祈求解决方案。
谢谢
$

公共DataTable lees()
{
字符串ConnectString =" Server = localhost;数据库= AA;用户
id = uniserver;密码= aa;连接超时= 100;" ;;
DataSet _DataSet = new DataSet();
string StoredProcedure =" S_aa";
using (SqlConnection _SqlConnection = new SqlConnection(ConnectString))
{
使用(SqlDataAdapter _SqlDataAdapter = new
SqlDataAdapter(StoredProcedure,_SqlConnection))
{
尝试
{

_SqlDataAdapter.SelectCommand.CommandType = CommandT ype.StoredProcedure;
_SqlDataAdapter.Fill(_DataSet,StoredProcedure);
_SqlDataAdapter.SelectCommand = null;
}
catch(SqlException e)
{
Console.WriteLine(StoredProcedure + e.Message + e.Stac kTrace);
}
}
} return _DataSet.Tables [0];
}
Hello,
I again ask for help on the next problem, a previous question did not
give a solution.

The method at the bottom of this message leaves a reference to somethig,
as far as I can tell to the _sqladapter variable. As you can see I use
the ''using'' statement so the adapter and the connection should be neatly
disposed of.
But it doesn''t!
I will be praying for a solution.
Thanks
Frank
public DataTable lees()
{
string ConnectString="Server= localhost; database=aa; User
id=uniserver;password=aa;Connect Timeout=100;";
DataSet _DataSet= new DataSet();
string StoredProcedure="S_aa";
using (SqlConnection _SqlConnection= new SqlConnection(ConnectString))
{
using (SqlDataAdapter _SqlDataAdapter = new
SqlDataAdapter(StoredProcedure,_SqlConnection))
{
try
{

_SqlDataAdapter.SelectCommand.CommandType=CommandT ype.StoredProcedure;
_SqlDataAdapter.Fill(_DataSet,StoredProcedure);
_SqlDataAdapter.SelectCommand=null;
}
catch (SqlException e)
{
Console.WriteLine(StoredProcedure+e.Message+e.Stac kTrace);
}
}
}
return _DataSet.Tables[0];
}




Ignacio,

我尝试了继承,但是我在''公共类'

newclass:SqlDataAdapter''时收到错误。

Do我必须以另一种方式做到这一点吗?

问候

Frank

Ignacio Machin(.NET / C#MVP)" < ignacio.machin AT dot.state.fl.us>

schreef在bericht新闻:ud ************** @ TK2MSFTNGP14.phx.gbl .. 。
Ignacio,
I tried the inherit but I get an error at ''public class
newclass:SqlDataAdapter''.
Do I have to do that in another way?
Regards
Frank
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:ud**************@TK2MSFTNGP14.phx.gbl...
HI,

你怎么知道呢?

还要记住,GC不是确定性的,所有你可以保证的是
现在,执行此操作。从SqlDataAdapter继承并覆盖Dispose,然后你会看到它被调用的时间。
IIRC处理调用关闭,所以如果按预期调用它,则关闭连接并且对象已准备好成为GC。

干杯,

- << Ignacio Machin,
ignacio.machin at dot.state.fl.us <佛罗里达州交通局

弗兰克 < FR *** @ frank.com>在消息中写道
新闻:42 *********************** @ news.xs4all.nl ...


How do you know it?

Also remember that the GC is not deterministic, all you can assure is that
the Dispose method will be called ( cause of the using )

Now, do this. inherit from SqlDataAdapter and override Dispose , then you
will see when it''s called.
IIRC Dispose call Close , so if it''s called as expected the connection is
closed and the objects are ready to be GC.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:42***********************@news.xs4all.nl...
您好,
我再次就下一个问题请求帮助,之前的问题没有给出解决方案。

此消息底部的方法留下了对somethig的引用,据我所知,_sqladapter变量。正如你所看到的那样,我使用''using''声明,所以适配器和连接应该整齐地处理掉。
但它不会!
我会祈求解决方案。
谢谢
$

公共DataTable lees()
{
字符串ConnectString =" Server = localhost;数据库= AA;用户
id = uniserver;密码= aa;连接超时= 100;" ;;
DataSet _DataSet = new DataSet();
string StoredProcedure =" S_aa";
using (SqlConnection _SqlConnection = new SqlConnection(ConnectString))
{
使用(SqlDataAdapter _SqlDataAdapter = new
SqlDataAdapter(StoredProcedure,_SqlConnection))
{
尝试
{

_SqlDataAdapter.SelectCommand.CommandType = CommandT ype.StoredProcedure;
_SqlDataAdapter.Fill(_DataSet,StoredProcedure);
_SqlDataAdapter.SelectCommand = null;
}
catch(SqlException e)
{
Console.WriteLine(StoredProcedure + e.Message + e.Stac kTrace);
}
}
} return _DataSet.Tables [0];
}
Hello,
I again ask for help on the next problem, a previous question did not
give a solution.

The method at the bottom of this message leaves a reference to somethig,
as far as I can tell to the _sqladapter variable. As you can see I use
the ''using'' statement so the adapter and the connection should be neatly
disposed of.
But it doesn''t!
I will be praying for a solution.
Thanks
Frank
public DataTable lees()
{
string ConnectString="Server= localhost; database=aa; User
id=uniserver;password=aa;Connect Timeout=100;";
DataSet _DataSet= new DataSet();
string StoredProcedure="S_aa";
using (SqlConnection _SqlConnection= new SqlConnection(ConnectString))
{
using (SqlDataAdapter _SqlDataAdapter = new
SqlDataAdapter(StoredProcedure,_SqlConnection))
{
try
{

_SqlDataAdapter.SelectCommand.CommandType=CommandT ype.StoredProcedure;
_SqlDataAdapter.Fill(_DataSet,StoredProcedure);
_SqlDataAdapter.SelectCommand=null;
}
catch (SqlException e)
{
Console.WriteLine(StoredProcedure+e.Message+e.Stac kTrace);
}
}
}
return _DataSet.Tables[0];
}




这篇关于引用未被删除重新访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆