Exemplo n.º 1
0
        public string[] readSQLHead()
        {
            SQLdispose myDispose = new SQLdispose();

            string[] myStr = myDispose.readeColumn();

            return(myStr);
        }
Exemplo n.º 2
0
        public void appendData(string column, string values)
        {
            //string column = "DataTime,PH,B_ID";
            //string values = "2018/04/12,3.65,30";

            SQLdispose myDispose = new SQLdispose();

            myDispose.appendData(column, values);
        }
Exemplo n.º 3
0
        //读取数据库中上一次存入的数据(末尾13行)
        public DataTable readSQL()
        {
            DataTable  mytable   = new DataTable();
            SQLdispose myDispose = new SQLdispose();
            string     strSQL    = "select top 14 * from DataInfo order by id desc ";

            mytable = myDispose.ExecuteWithReturn(strSQL);
            int ccc = 0;

            return(mytable);
        }
Exemplo n.º 4
0
        //向数据库中追加一table的数据
        public void appendDataToSQL(List <upDate> rb)
        {
            int bengCount = 14;

            count++;
            Console.WriteLine("@@@" + DateTime.Now.ToString());
            DataTable sqlTable = new DataTable();

            //从数据库中读取bengCount条数据
            string     strSQL    = "select top 14 * from DataInfo order by id desc ";
            SQLdispose myDispose = new SQLdispose();

            sqlTable = myDispose.ExecuteWithReturn(strSQL);

            //读取字段
            foreach (DataRow nowRow in sqlTable.Rows)
            {
                int num222 = Convert.ToInt32(nowRow["ID"]) + bengCount;
                nowRow["ID"]       = num222;
                nowRow["DateTime"] = DateTime.Now;
            }
            for (int i = 0; i < rb.Count; i++)
            {
                string[] str3 = rb[i].key.Split('.');
                if (sqlTable.Columns.Contains(str3[2]) == false)
                {//如果数据表有没有该tag列,在表中新增一列
                    sqlTable.Columns.Add(str3[2], typeof(string));
                }
                // string coulumName = str3[2];
                foreach (DataRow nowRow in sqlTable.Rows)
                {
                    if (str3[1] == nowRow["bengName"].ToString().Trim())
                    {//如果泵站名在该row(行),则将数据更新到表中对应位置
                        //nowRow["PH"] = 3.1516;
                        nowRow[str3[2]] = rb[i].Value;
                        break;
                    }
                }
            }
            DataView dv = new DataView(sqlTable);

            dv.Sort  = "id asc";
            sqlTable = dv.ToTable();
            //DataTable ceshiTable = sqlTable;
            myDispose.appendToSQL(sqlTable);
            // return true;
        }