(.net)如何指定sqlconnection的出站(本地)端口(.net) [英] (.net) How to specift outbound(local) port for sqlconnection (.net)

查看:343
本文介绍了(.net)如何指定sqlconnection的出站(本地)端口(.net)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用sql server 2008计算机测试数据库连接性和负载性能.我想创建大量连接和查询并将其发送到服务器.这是在C#和.net 4.0中完成的.

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

推荐答案

SqlConnection myConnection = new SqlConnection(初始目录= Northwind;数据源= 10.10.10.10:8000;集成安全性= SSPI;);
字符串myInsertQuery =将客户插入(CustomerID,CompanyName)Values(" NWIND,"罗斯文交易者)";
SqlCommand myCommand =新的SqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();

启动一堆线程并在每个线程内循环运行以上代码.
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.


这篇关于(.net)如何指定sqlconnection的出站(本地)端口(.net)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆