回复 楼主 titanxxc
/心率
byte[] bytebuf1 = new byte[3];
bytebuf1[0] = arrMsgRec[1];
bytebuf1[1] = arrMsgRec[2];
bytebuf1[2] = arrMsgRec[3];
string str1 = Encoding.ASCII.GetString(bytebuf1);
//收缩压
byte[] bytebuf2 = new byte[3];
bytebuf2[0] = arrMsgRec[4];
bytebuf2[1] = arrMsgRec[5];
bytebuf2[2] = arrMsgRec[6];
string str2 = Encoding.ASCII.GetString(bytebuf2);
//舒张压
byte[] bytebuf3 = new byte[3];
bytebuf3[0] = arrMsgRec[7];
bytebuf3[1] = arrMsgRec[8];
bytebuf3[2] = arrMsgRec[9];
string str3 = Encoding.ASCII.GetString(bytebuf3);
string date = DateTime.Now.ToString();
DateTime d = DateTime.Parse(date);
using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;
AttachDBFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;
User Instance=True"))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
= "insert into Table3(心率,收缩压,舒张压,采集时间)values(@心率,@收缩压,@舒张压,@采集时间)";
cmd.Parameters.Add(new SqlParameter("心率", str1));
cmd.Parameters.Add(new SqlParameter("收缩压", str2));
cmd.Parameters.Add(new SqlParameter("舒张压", str3));
cmd.Parameters.Add(new SqlParameter("采集时间", date));
cmd.ExecuteNonQuery();
}
}
不太对