Re: ExecuteNonQuery stops program

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Sahil Malik (contactmethrumyblog_at_nospam.com)
Date: 01/17/05


Date: Sun, 16 Jan 2005 21:33:33 -0500

Okay so ..

You don't have a transactional scenario.
The code hangs after an unpredicatable # of updates.

Are you getting the same behavior when you run 13117 updates from Query
Analyzer?

Can you run a quick experiment?
a) Backup your database.
b) Run your code - see at what count it blocks.
c) Now restore the db
d) Run the code again - see at what count it blocks.

Does it block at exactly the same count between b and d?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik

"rafal" <rx409@gazeta.pl> wrote in message
news:cseq33$6aq$1@inews.gazeta.pl...
>
> Użytkownik "Sahil Malik" <contactmethrumyblog@nospam.com> napisał w
> wiadomości news:uivGzOA$EHA.1452@TK2MSFTNGP11.phx.gbl...
>> Are these commands a part of a transaction?
>>
>> - Sahil Malik
>> http://dotnetjunkies.com/weblog/sahilmalik
>>
>>
>> "rafal" <rx409@gazeta.pl> wrote in message
>> news:csecfr$50q$1@inews.gazeta.pl...
>> > I run this code below which is part of method.
>> > ds.Tables["tabelka"].Rows.Count has always value 13117 but sometimes
>> > the
>> > code executes only 1000 or 12000 times etc and freezes without error or
>> > exception not coming to the end of the method. In debug window it
>> > prints
>> > "before" which means it stops during or before executing
>> > upd.ExecuteNonQuery();
>> > I don' know what is going on. Thanks for help.
>> >
>> >
>> > for (int y = 0; y < ds.Tables["tabelka"].Rows.Count; y++)
>> > {
>> > string account_id = ds.Tables["tabelka"].Rows[y][0].ToString();
>> > string date = ds.Tables["tabelka"].Rows[y][1].ToString();
>> > int temp1 = 0;
>> > double temp2 = 0.00;
>> > int val = 0;
>> > val = y/1874;
>> > string updateCommand = "update wielka set
> "+columnName+"="+val.ToString()+
>> > "
>> > where account_id="+account_id+" and date="+date;
>> > SqlConnection sqlConnection3 = new SqlConnection(connString);
>> > SqlCommand upd = new SqlCommand(updateCommand, sqlConnection3);
>> > if (sqlConnection3.State.ToString() == "Closed")
>> > {
>> > sqlConnection3.Open();
>> > }
>> > try
>> > {
>> > Console.WriteLine("before");
>> > upd.ExecuteNonQuery();
>> > Console.WriteLine("discretization "+y);
>> > }
>> > catch (Exception exc)
>> > {
>> > Console.WriteLine("Exception 3: "+exc.ToString());
>> > Console.WriteLine("UpdateCommand: "+updateCommand);
>> > }
>> > sqlConnection3.Close();
>> > }
>> >
>> >
>>
>>
> No, separate inserts into database.
>
>



Relevant Pages

  • Re: how to move location of default database???? plz!
    ... fine, cool about the database, it probably amounts to how much tagging one ... updates - i woulda rolled them all back. ... No recent version of Windows does ... well when you have less than about 50MB to 100MB of free space. ...
    (microsoft.public.windowsmedia.player)
  • Re: Update Sql Server 2000 database from the HP3000
    ... collects those updates via ODBC every 10 or so seconds. ... essentially update the SQL database at the same time as the main ... Authorised and regulated by the Financial Services Authority. ...
    (comp.sys.hp.mpe)
  • Re: The right database for the job?
    ... Note that "many updates ... > the programmer that have to fix somebody elses code and/or database ... > devices under its control, it connects to a central "DB server" program ...
    (comp.databases)
  • Re: A different definition of MINUS, Part 3
    ... can actually be the value of the database at any set point in time. ... updates, on the other hand, assert which possible value for the ... neither the algebra nor the calculus are sufficient when it comes to ... To extend the analogy to view updates, we also have an input delta ...
    (comp.databases.theory)
  • Re: Disk transfers
    ... database software rather than in the application itself) is to capture the change in a relatively small update record in a log - which can be supported effectively in a relatively small amount of NVRAM if performance is important, rather than throwing GB of NVRAM at a generic disk write-back cache, and which in any event can effectively batch many such updates into a single log write if they occur very close to each other - and then later perform the eventual on-disk structural updates lazily, in the background, and possibly in bulk. ... though I'm not sure how the latter would vary all that much (unless you're just referring to the difference between disk and NVRAM performance). ...
    (comp.arch)