Re: Need realy help! Nobody there who knows a solution for my memory-error on WM5??



You need to call dr.Close(); I don't know if that's what's causing your problem, but it's worth a try. I don't generally dispose of SqlCeCommand objects and often just reuse them, but you need to be sure to also call Close() on your connection when you are finished with it (which I believe calls Dispose internally.)

--
Ginny


"MoonBreaker" <Scharf.Rene@xxxxxxxxxxxxxx> wrote in message news:1176384810.166627.49480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Pete

I have not used dispose before (because cmd was an "Global"-Object in
Form1) but after your mail i tried it in this case:

cmd = new SqlCeCommand();
cmd.Connection = conEnceDB;

cmd.CommandText = sSqlString;
dr = cmd.ExecuteReader();
while (dr.Read())
{
.....
}

cmd.Dispose();

in every method I'm using cmd.

The error occours at the same time :-(

René


On 12 Apr., 10:10, "Pete Vickers [MVP]" <pete at gui - innovations dot
com> wrote:
Hi,
do you dispose of cmd when you have finished with it?

Pete


.



Relevant Pages

  • Re: Question about Using and resources
    ... Using "Using" is really about when to call Dispose. ... Do not explicitly call Dispose on classes deriving from ... Using CMD As New OleDbCommand ... Dim vCID As New Collection ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Yet another DataAdapter and Transaction problem
    ... Correc me if I'm wrong, this would be the correct way to do it: ... Start transaction ... dispose the data adapter and its commands? ... SqlCeCommand cmd = dbAdapter.SelectCommand; ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Why use Prepare() if this MS BUG exists ?
    ... The key is that one needs to call Dispose when finished with the command ... In the case where Prepare is called and the SqlCeCommand object is used ... > protected SqlCeCommand GetMyCommand() ... > If I need to Dispose of the cmd after I use it, then if I use it again ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Why use Prepare() if this MS BUG exists ?
    ... The key is that one needs to call Dispose when finished with the command ... In the case where Prepare is called and the SqlCeCommand object is used ... > protected SqlCeCommand GetMyCommand() ... > If I need to Dispose of the cmd after I use it, then if I use it again ...
    (microsoft.public.sqlserver.ce)
  • Yet another DataAdapter and Transaction problem
    ... Fill dataset with data returned by webservice ... This is not actually using the transaction. ... dispose the data adapter and its commands? ... SqlCeCommand cmd = dbAdapter.SelectCommand; ...
    (microsoft.public.dotnet.framework.compactframework)

Loading