c# - Invalid attempt to read - Is possible using Action? -


public void executeaction(mysqlcommand query, action<mysqldatareader> action)     {         _connection.open();         query.connection = _connection;         using(var reader = query.executereader())         {             while (reader.read())             {                 action(reader);             }             reader.close();         }         _connection.close();     } 

is possible this? getting error "invalid attempt read when reader closed".

this piece of code i'm using:

private void updaterecords()     {         var query = string.format("select * {0}", _table);         var cmd = new mysqlcommand(query);         _db.executeaction(cmd, reader =>                                    {                                        var rows = new list<object>();                                        (var = 0; < reader.fieldcount; i++)                                        {                                            if (reader.isdbnull(i)) continue;                                            var name = reader.getname(i);                                            if (!_fields.contains(name)) _fields.add(name);                                            rows.add(reader.getvalue(i));                                        }                                        _records.add(new record(_fields, rows));                                    });     } 

i'm trying store records of database's tables dynamic classes inside program. when try add dynamically mysql data classes error.

another question related: there library can make me? it's lot of code not have write down, first time approaching mysql , c#, don't have type of knowledge. help.

update: error connection opened, mysql making me curse(i'm used mongodb...)

i solved problem. didn't know cannot use more 1 time same connection call different readers, had create new 1 every time need query db.

mysql - multiple result sets


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -