Click here to Skip to main content
15,887,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I'v a following statement with which I'm creating 100 tables and inserting values into it respectively.

cmd1.ExecuteNonQuery();


But its throwing a error like "time out exception" and the above is not executing completely...

I think the .net compiler is executing the statement fastly where as it requires bit more time..

As per i'v to use Threads concept but not clear...
Can u help me to solve issue.
Posted
Comments
Indivara 31-Jan-11 3:51am    
Do you really have to do 100 tables in a single SQL statement?
Sergey Alexandrovich Kryukov 31-Jan-11 3:53am    
Needs more detail explanation of the goals. Also, please perform the search on "thread" or "threading" in Answers -- I along gave many answers on the topic, other members too. After that, you could ask more defined question.
Thanks for understanding.
--SA
krishna kishore58 31-Jan-11 3:57am    
yes I'v to do...

The time out exception is most likely to be waiting for a response from the SQL server (or whatever database you are using). I would strongly suggest reducing the number of tables and values you insert in a single command: this could take some considerable time and is probably outside the time out limits for your database system to respond. You could increase the limits with your database manager (google "increase timeout sql server" for information on how), but it would be better to look at converting your single monolithic command into a number of commands, possibly transacted so you can roll back in case of failure.
 
Share this answer
 
Comments
krishna kishore58 31-Jan-11 4:01am    
thanks 4 replying...Ur r8 but the all the command structure to create 100 tables and to insert values are available in a file. And I'm taking the content of the file into string and then executing the string ...Hope u understand..
You can set cmd1.CommandTimeout. You have to specify time in seconds.

By default it is 30 seconds. Your procedure may be taking longer than that.

I think, creating 100 tables won't take much time. But I don't know how much data you are adding to them! I think if you are not populating much data, try 300 as timeout. You can increase timeout if required.
 
Share this answer
 
v3
Comments
krishna kishore58 31-Jan-11 3:58am    
But i donno how much time that statement requires...
Prerak Patel 31-Jan-11 4:01am    
You can guess the expected time for execution, or you can split the queries.
Prerak Patel 31-Jan-11 4:02am    
I think, creating 100 tables won't take much time. But I don't know how much data you are adding to them!
krishna kishore58 31-Jan-11 4:03am    
I'm not writing all the queries manually. They r available in a file. And i'm copying the file content to string and executing that string...
Prerak Patel 31-Jan-11 4:06am    
Then try the max you can imagine. I think if you are not populating much data, try 300 as timeout.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900