Re: ExecuteNonQuery stops program
From: W.G. Ryan eMVP (WilliamRyan_at_NoSpam.gmail.com)
Date: 01/16/05
- Next message: W.G. Ryan eMVP: "Re: Performace problem with DataView.RowFilter"
- Previous message: Joe: "Re: Performace problem with DataView.RowFilter"
- In reply to: rafal: "ExecuteNonQuery stops program"
- Next in thread: rafal: "Re: ExecuteNonQuery stops program"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 16 Jan 2005 17:47:09 -0500
I'd Debug.Writeline the command that's being fired and see if it will work
in Query Analyzer - or run a trace and see what's happening w/ it. I've
never quite seen that behaviour you mention - but using Profiler will help
you see what's going on back there.
Just as an aside - you may want to paramaterize your query for performance,
security etc. Also, if this is being called 10,000 times or whatever, just
check that sqlConnection3.State==ConnectionState.Closed - that way you
aren't creating a string each time just to compare it to one. In a loop
this big that could affect performance a little . I'd also just trap a
SqlException here b/c the line your trying - that should be the only type of
exception that would be raised. Just on GP I'd bump the Close into a
finally block.
Good Luck
Bill
--
W.G. Ryan MVP (Windows Embedded)
TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"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();
> }
>
>
- Next message: W.G. Ryan eMVP: "Re: Performace problem with DataView.RowFilter"
- Previous message: Joe: "Re: Performace problem with DataView.RowFilter"
- In reply to: rafal: "ExecuteNonQuery stops program"
- Next in thread: rafal: "Re: ExecuteNonQuery stops program"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|