Insert constantly updated value to database

Hey, i just started to learn c# and would really appriciate some guidance, I am using a microcontroller to read 3 values and now im showing them in a Windows Application textbox thats updated once every 2 second with a new row containing the values.

private void displaydate_event(object sender, EventArgs e) { datetime = DateTime.Now;

 string time = +datetime.Year + "-" + datetime.Month + "-" + datetime.Day + " " + datetime.Hour + ":" + datetime.Minute + ":" + datetime.Second; string clock = +datetime.Hour + ":" + datetime.Minute + ":" + datetime.Second; string[] in_dataSplit = myport.ReadLine().Split(','); data_tb.AppendText(" " + time + "\t\t" + in_dataSplit[0] + "C\t\t" + in_dataSplit[2] + "\t\t" + in_dataSplit[1] + "\n");//Show all textBox1.AppendText(clock + "\t\t" + in_dataSplit[0] + "\n"); //Show light in seperate box textBox2.AppendText(clock + "\t\t" + in_dataSplit[2] + "\n"); //Show temperature in seperate box textBox3.AppendText(clock + "\t\t" + in_dataSplit[1] + "\n");//Show moisture in seperate box textBox8.AppendText(clock + "\t\t" + in_data + "\n"); 

}

But the problem is that i would like to do charts with these numbers, and to do that i assume i need a database. I have been sitting for 2 days trying to insert these values in to a local microsoft SQL DB but i really cant figure it out.

Whats the best way to do this? or more likley, the easiest way to do this… My connection string is: Data Source=(LocalDB)\v11.0;AttachDbFilename="d:\OneDrive\project one\C#\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf";Integrated Security=True

Thanks

by ziooon via /r/csharp

Leave a Reply