Re: SqlCe Insert Record Performance
- From: "Chris Tacke, eMVP" <ctacke@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 20 May 2005 09:31:49 -0400
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
>>>
>>>
>
.
- Follow-Ups:
- Re: SqlCe Insert Record Performance
- From: Enrico Pavesi
- Re: SqlCe Insert Record Performance
- References:
- SqlCe Insert Record Performance
- From: wyghf
- Re: SqlCe Insert Record Performance
- From: Sergey Bogdanov
- Re: SqlCe Insert Record Performance
- From: Enrico Pavesi
- Re: SqlCe Insert Record Performance
- From: Sergey Bogdanov
- Re: SqlCe Insert Record Performance
- From: Enrico Pavesi
- SqlCe Insert Record Performance
- Prev by Date: Re: Full Screen
- Next by Date: Refresh Today Screen
- Previous by thread: Re: SqlCe Insert Record Performance
- Next by thread: Re: SqlCe Insert Record Performance
- Index(es):
Relevant Pages
|