Connection problem


I'm having some difficulty with connecting an executeing sql statements against the sql server 2000. I'm working in vs2005. I used the folowing code:

SqlConnection myConnection = new SqlConnection("user id=username;" +

"password=pass;server=servname;" +
"Trusted_Connection=yes;" +

"database=databasename; " + "connection timeout=30");




catch (Exception ef)


SqlCommand myCommand1 = new SqlCommand("delete tabele1", myConnection);
SqlCommand myCommand = new SqlCommand("INSERT INTO tabele1(column1, column2) " +

"select month(s.column3),sum(s.column4) from tabele2 s group by month(s.column3) order by month(s.column3)", myConnection);myCommand1.ExecuteNonQuery();



catch (Exception er)

Problem is that that I get an error timeout expired or server not responding on the line myCommand.ExecuteNonQuery();

When I compile the application 3 times then it works. First two times it throwse the exception, and after that it works fine. If I start the servers query analyzer of profiler withe the same name and password the program works fine from the first time. There is obviously some connection problem, but what....

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!