MSSQL using C# and Charting Libraries

using System.Data.SqlClient;
using System.Windows.Forms.DataVisualization.Charting;
...
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            string start;
            var last = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day).AddDays(-3); ;
            string end;
            SqlCommand myCMD = new SqlCommand();
 
            SqlDataReader myReader;
 
            conn.ConnectionString = "integrated security=SSPI;data source=SERVER_NAME;persist security info=true;initial catalog=Electrolytic; Connect Timeout=120;";
            start = DateTime.Now.ToString("MM/dd/yyyy");
            last = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day).AddDays(-3);
            end = last.ToString("MM/dd/yyyy");
            myCMD = new SqlCommand("SELECT Sample_Date, XXXXXXX FROM cur_Cell_East_Huron2 WHERE XXXXXXXX is not null and Sample_Date BETWEEN \'" + end + "\' and \'" + start + "\' ORDER by Sample_Date ASC ", conn);
            conn.Open();
            myReader = myCMD.ExecuteReader();
            chart1.DataBindTable(myReader, "Sample_Date");
            myReader.Close();
            conn.Close();
            chart1.Series["XXXXXXXX"].ChartType = SeriesChartType.FastLine;
            chart1.Titles["Title1"].Text = "Cell 501";
            chart1.Legends["Legend1"].Enabled = false;

Retrieve Data from OSI PI and C#

using System.Data.OleDb;

            string int_Total;
            string time;
            int i = 0;
            string lines = "";
            string start = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            var last = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day).AddDays(-15);
            string end = last.ToString("yyyy-MM-dd HH:mm:ss");
            OleDbConnection DBPIConn;
            OleDbCommand DBPICommand;
            OleDbDataReader myPiDataReader;
            DBPIConn = new OleDbConnection();
             try
            {
Tags: 
Subscribe to Chris House RSS
password