cmd.executeNonWQuery() freezes

Jan 16 2005 10:18 AM
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(); }

Answers (1)