Click here to Skip to main content
15,887,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to test database connectivity and load performance with a sql server 2008 machine. I want to create and send a large amount of connections and queries to the server. this is being done in C# and .net 4.0
Posted
Updated 15-Apr-10 6:51am
v2

1 solution

SqlConnection myConnection = new SqlConnection("Initial Catalog=Northwind;Data Source=10.10.10.10:8000;Integrated Security=SSPI;");
string myInsertQuery = "INSERT INTO Customers (CustomerID, CompanyName) Values('NWIND', 'Northwind Traders')";
SqlCommand myCommand = new SqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();

start a bunch of threads and run the above code in a loop within each thread.
 
Share this answer
 
v2
Comments
guyanese4life2 24-May-10 15:27pm    
I figured it out... I just evoked an async delegate in a loop instead of starting new threads.
guyanese4life2 21-Jun-10 15:51pm    
myCommand.BeginExecuteNonQuery();
myCommand.EndExecuteNonQuery() - to catch results

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