c#测试本机sql运算速度的代码示例分享
本文导语: 代码如下:using System;using System.Collections.Generic;using System.Text;using System.Data.SqlClient; namespace ConsoleApplication2{ class Program { static void Main(string[] args) { SqlConnection conn = new SqlConnection(); ...
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
SqlConnection conn = new SqlConnection();
SqlCommand comm = new SqlCommand();
DateTime t1, t2;
int count = 10000; //循环次数
string times;
conn.ConnectionString = "Data Source=.;Initial Catalog=Server;Integrated Security=True";
comm.CommandText = "insert into test (Cid,Cvalue) values('1','1')"; //数据插入
comm.Connection = conn;
Console.WriteLine("开始插入数据rn开始时间:" +(t1=DateTime.Now).ToLongTimeString());
try
{
conn.Open();
for (int i = 1; i