米拉德尔
会员
- 已加入
- 2020年8月16日
- 留言内容
- 8
- 编程经验
- Beginner
大家好,
我在添加带有SQL福彩12选5走势图的图表时遇到一些问题。
为了定义问题,我需要从传感器收集福彩12选5走势图,将其存储在福彩12选5走势图库中,并按时间降序格式将其用作图表和福彩12选5走势图网格。
下面的代码是项目的一个简单示例部分,问题是,每当我启动应用程序时,福彩12选5走势图就会显示在福彩12选5走势图网格视图和图表上,但是图表福彩12选5走势图就像之字形线一样。
每条新生产线只是传感器的末端&起始值(请参见所附图片:此处[67,43],[65,43],[63,43],...)
另一个问题是福彩12选5走势图库中没有福彩12选5走势图存储,并且所有字段都为空。
项目以zip文件形式附加。
感谢您一如既往的帮助。
我在添加带有SQL福彩12选5走势图的图表时遇到一些问题。
为了定义问题,我需要从传感器收集福彩12选5走势图,将其存储在福彩12选5走势图库中,并按时间降序格式将其用作图表和福彩12选5走势图网格。
下面的代码是项目的一个简单示例部分,问题是,每当我启动应用程序时,福彩12选5走势图就会显示在福彩12选5走势图网格视图和图表上,但是图表福彩12选5走势图就像之字形线一样。
每条新生产线只是传感器的末端&起始值(请参见所附图片:此处[67,43],[65,43],[63,43],...)
另一个问题是福彩12选5走势图库中没有福彩12选5走势图存储,并且所有字段都为空。
项目以zip文件形式附加。
感谢您一如既往的帮助。
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Web.UI.DataVisualization.Charting;
namespace p1
{
public partial class Form1 : Form
{
SqlConnection conn = new SqlConnection();
SqlCommand cmd1 = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
int inputData;
public Form1()
{
InitializeComponent();
}
private void BtnStart_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void Timer1_Tick(object sender, EventArgs e)
{
serialPort1.Open();
serialPort1.Write("1");
txtData.Text = serialPort1.ReadLine();
serialPort1.Close();
SqlCommand c1 = new SqlCommand();
c1.CommandText = "insert into tblCount values (@p1,@p2)";
inputData = Int32.Parse(txtData.Text);
c1.Parameters.AddWithValue("p1",DateTime.Now.ToString());
c1.Parameters.AddWithValue("p2", inputData);
c1.Connection = conn;
c1.ExecuteNonQuery();
fillgrid();
}
private void BtnStop_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
}
private void Form1_Load(object sender, EventArgs e)
{
conn.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True";
conn.Open();
fillgrid();
}
void fillgrid(string s="select * from tblCount")
{
cmd1.CommandText = s;
cmd1.Connection = conn;
da.SelectCommand = cmd1;
ds.Clear();
da.Fill(ds, "T1");
dataGridView1.DataBindings.Clear();
dataGridView1.DataBindings.Add("datasource", ds, "T1");
dataGridView1.Sort(dataGridView1.Columns[0], 清单SortDirection.Descending);
txtData.DataBindings.Clear();
//===================================================Chart1
SqlConnection conn2 = new SqlConnection();
conn2.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True";
conn2.Open();
SqlCommand cmd2 = new SqlCommand("select sensorValue from tblCount order by dateTime desc", conn2);
SqlDataReader reader = cmd2.ExecuteReader();
Series sr = new Series();
while (reader.Read())
chart1.Series[0].Points.AddY(reader.GetInt32(0));
}
}
}