Re: SqlCe Insert Record Performance

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Sure, but when will that happen? Calling Dispose gives you control. The GC
may not call it for minutes, hours or even days depending on the app.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


"Enrico Pavesi" <nxpavesi@xxxxxx> wrote in message
news:%2332GjUTXFHA.3176@xxxxxxxxxxxxxxxxxxxxxxx
> Ok but when an object is Garbage collected dispose is called.
> Correct?
>
> "Sergey Bogdanov" <sergey.bogdanov@xxxxxxxxx> ha scritto nel messaggio
> news:%23unb8fRXFHA.3032@xxxxxxxxxxxxxxxxxxxxxxx
>> You will need to Dispose any objects that require it (i.e. SqlCeCommand
>> uses unmanaged resources, when you call Dispose you will release it).
>>
>> --
>> Sergey Bogdanov
>> http://www.sergeybogdanov.com
>>
>>
>> Enrico Pavesi wrote:
>>> Why SqlCeCommand.Dispose??
>>>
>>> GC does not do that ?
>>>
>>> Thanks
>>>
>>> "Sergey Bogdanov" <sergey.bogdanov@xxxxxxxxx> ha scritto nel messaggio
>>> news:eQkoVcQXFHA.796@xxxxxxxxxxxxxxxxxxxxxxx
>>>
>>>>You did not say how many items you have in the otask variable. Also you
>>>>have potential memory leaks in your code - do not forget to call
>>>>SqlCeCommand.Dispose.
>>>>
>>>>--
>>>>Sergey Bogdanov
>>>>http://www.sergeybogdanov.com
>>>>
>>>>
>>>>wyghf wrote:
>>>>
>>>>>I use slqce database to store master-detail table.It took too long to
>>>>>insert data.
>>>>>Could anyone give me some suggestion on how to improvement it.Following
>>>>>is my code:
>>>>> public static void RecordTask(ArrayList otask)
>>>>> {
>>>>> string scmd1 = "INSERT INTO TASK (date,taskname) VALUES
>>>>> ('{0}','{1}')";
>>>>> string scmd2 = "INSERT INTO ASKLIST
>>>>> (TASKID,tlist,state,begintime,endtime) VALUES
>>>>> ({0},'{1}',{2},'{3}','{4}')";
>>>>>
>>>>> SqlCeConnection cn = new SqlCeConnection("Data
>>>>> Source="+dbpath+@"\PDAKEYDB.SDF");
>>>>>
>>>>>try
>>>>>{
>>>>>SqlCeCommand sqlcmd = cn.CreateCommand();
>>>>>cn.Open();
>>>>>sqlcmd.CommandText = string.Format(scmd1,DateTime.Now,Config.TaskName);
>>>>>sqlcmd.ExecuteNonQuery();
>>>>>
>>>>>sqlcmd.CommandText = "Select @@IDENTITY";
>>>>>object o = sqlcmd.ExecuteScalar(); int
>>>>>taskid = (int) ((System.Data.SqlTypes.SqlDecimal) o).Value; foreach
>>>>>(Operate op in otask) {
>>>>>sqlcmd.CommandText =
>>>>>string.Format(scmd2,taskid,op.Description,op.OpResult,DateTime.Now,DateTime.Now);
>>>>>sqlcmd.ExecuteNonQuery();
>>>>>}
>>>>>
>>>>>}
>>>>>catch (SqlCeException sex)
>>>>>{
>>>>>MessageBox.Show(sex.Message);
>>>>>}
>>>>>catch (Exception ex)
>>>>>{
>>>>>MessageBox.Show(ex.Message);
>>>>>}
>>>>>finally
>>>>>{
>>>>>cn.Close();
>>>>>}
>>>>>}
>>>>>
>>>>>
>>>>>Thanks in advance,
>>>>>wyghf
>>>
>>>
>


.



Relevant Pages

  • Re: Memory Leak Experts!!!!
    ... > However as soon as app is restored all this memory is swapped back. ... > DataSet Dispose for example doesn't touch tables and rows. ... > free references in due time. ...
    (microsoft.public.dotnet.framework.performance)
  • RE: ObjectDisposedException
    ... Setting Parent of a control is the same as adding your control to the ... Visual Developer - Device Application Development MVP ... I definitely do not dispose of the form or these buttons before the ... the app and definitely have not got there yet). ...
    (microsoft.public.dotnet.framework.compactframework)
  • ObjectDisposedException
    ... They are being thrown on a button/control which are part of a ... I definitely do not dispose of the form or these buttons before the ... Obviously I am still holding a reference to the control, ... The latest exception occured when a user tapped on a button and the app went ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Memory Leak Experts!!!!
    ... my intention is get my app to work as best as i can from my dev desktop. ... multiprocessor and how .NET uses the mscorsvr.dll ... and Dispose calls for internal objects. ... > number of created references. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: out of memory
    ... that i presume automatically calls dispose. ... You normally dont stress test on dev. ... IOW, the purpose of Memory ... A good practice is to put the app first on a staging ...
    (microsoft.public.dotnet.framework.aspnet)