internal static DbDataReader Create(SQLiteCommand command, CommandBehavior behavior)
        {
            DbDataReader dataReader = new SQLiteDataReader(command, behavior);

            dataReader.NextResult();
            return(dataReader);
        }
Beispiel #2
0
 public override int ExecuteNonQuery()
 {
     using (SQLiteDataReader reader = this.ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult))
     {
         while (reader.NextResult())
         {
         }
         return(reader.RecordsAffected);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Execute the command and return the number of rows inserted/updated affected by it.
        /// </summary>
        /// <returns></returns>
        public override int ExecuteNonQuery()
        {
            CheckDisposed();
            SQLiteConnection.Check(_cnn);

            using (SQLiteDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult))
            {
                while (reader.NextResult())
                {
                    ;
                }
                return(reader.RecordsAffected);
            }
        }
        public DataSet DataReader2DataSet ( SQLiteDataReader reader )
        {
            DataSet dataSet = new DataSet ( );
            do
            {
                // Create new data table

                DataTable schemaTable = reader.GetSchemaTable ( );
                DataTable dataTable = new DataTable ( );

                if ( schemaTable != null )
                {
                    // A query returning records was executed

                    for ( int i = 0 ; i < schemaTable.Rows.Count ; i++ )
                    {
                        DataRow dataRow = schemaTable.Rows [ i ];
                        // Create a column name that is unique in the data table
                        string columnName = ( string ) dataRow [ "ColumnName" ];
                        // Add the column definition to the data table
                        DataColumn column = new DataColumn ( columnName , ( Type ) dataRow [ "DataType" ] );
                        dataTable.Columns.Add ( column );
                    }

                    dataSet.Tables.Add ( dataTable );

                    // Fill the data table we just created

                    while ( reader.Read ( ) )
                    {
                        DataRow dataRow = dataTable.NewRow ( );

                        for ( int i = 0 ; i < reader.FieldCount ; i++ )
                            dataRow [ i ] = reader.GetValue ( i );

                        dataTable.Rows.Add ( dataRow );
                    }
                }
                else
                {
                    // No records were returned

                    DataColumn column = new DataColumn ( "RowsAffected" );
                    dataTable.Columns.Add ( column );
                    dataSet.Tables.Add ( dataTable );
                    DataRow dataRow = dataTable.NewRow ( );
                    dataRow [ 0 ] = reader.RecordsAffected;
                    dataTable.Rows.Add ( dataRow );
                }
            }
            while ( reader.NextResult ( ) );
            return dataSet;
        }
        private static File ParseWithReferences(SQLiteDataReader dr)
        {
            if (!dr.Read()) return null;

            File file = Parse(dr);

            List<Tag> tags = new List<Tag>();
            dr.NextResult();

            while (dr.Read())
            {
                Tag tag;
                tags.Add(tag = new Tag
                {
                    Id = dr.GetInt32(0),
                    Description = dr.GetString(1)
                });

                object idTagTypeObj = dr.GetValue(2);
                if (idTagTypeObj != DBNull.Value)
                {
                    tag.TagType = new TagType
                    {
                        Id = dr.GetInt32(2),
                        Description = dr.GetString(3)
                    };
                }
            }

            file.Tags = tags;

            return file;
        }