1.主要是连接数据库并且想那列插入数据`
在这里 Stopwatch sw = new Stopwatch();
SqlConnection sqlConn = new SqlConnection(“server=.;DataBase=Data;uid=sa;pwd=123456”);//连接数据库
SqlCommand sqlComm = new SqlCommand();
sqlComm.CommandText = string.Format(“insert into Last(Jiancedian,Datatime,VRMSA,VRMSB)values(@p1,@p2,@p3,@p4)”);//参数化SQL
sqlComm.Parameters.Add("@p1", SqlDbType.VarChar); //sqlComm.Parameters.Add("@p0", SqlDbType.Int);
sqlComm.Parameters.Add("@p2", SqlDbType.DateTime);
sqlComm.Parameters.Add("@p3", SqlDbType.VarChar);
sqlComm.Parameters.Add("@p4", SqlDbType.VarChar);
sqlComm.CommandType = CommandType.Text;
sqlComm.Connection = sqlConn;
sqlConn.Open();
try插入代码片
2.定义字符串并且写入for循环
在这里插try
{
string[] arrayDe = { "设备001", "设备002", "设备003","设备004","设备005","设备006" };
string[] arrayVrA = {