示例#1
0
        // basic methods
        // get
        public String GetString(String key)
        {
            String value = null;

            using (SqlConnection sqlConnection = DB.NewSqlConnection()) {
                String     cmdText    = @"SELECT value FROM " + TableName + " WHERE name = " + QCDBClient.EscapeString(key);
                SqlCommand sqlCommand = new SqlCommand(cmdText, sqlConnection);
                sqlConnection.Open();
                Object r = sqlCommand.ExecuteScalar();
                if (r != null)
                {
                    value = r.ToString();
                }
                sqlConnection.Close();
            }
            return(value);
        }
示例#2
0
        public StreamingEventSource()
        {
            DB      = InitDB();
            Options = InitStreamingOptions();

            DB.CreateTable(TableName, ValueDefs);
            SqlConnection = DB.NewSqlConnection();
            SqlConnection.Open();

            // init the cursor and options
            String dropCursorCmd   = String.Format(@"DEALLOCATE  {0};", CursorName);
            String createCursorCmd = String.Format(@"DECLARE {0}  CURSOR Dynamic Read_Only
                    FOR SELECT * FROM {1} where row_id>={2}
              OPEN {0};", CursorName, TableName, Options.CurrentRow);

            DB.ExecuteNonQuery(createCursorCmd, SqlConnection);

            FetchNextCursorCmd   = String.Format(@"FETCH NEXT FROM {0};", CursorName);
            FetchPriorCursorCmd  = String.Format(@"FETCH PRIOR FROM {0};", CursorName);
            FetchScrollCursorCmd = String.Format(@"FETCH ABSOLUTE {0} FROM {1};", Options.CurrentRow, CursorName);

            ValueNames = ValueDefs.ToList()
                         .Select(def => def.ColumnName).ToArray();



            // skip to the unhappend event
            //while (true)
            //{
            Object[] rs = NextRow();

            if (rs != null)
            {
                if (IsValidRow(rs))
                {
                    //back one
                    PriroRow();
                    //break;
                }
                //else continue; // visited rows
            }
            //    else break;
            //}
        }