c# - mysql data read returning 0 rows from class -


I am implementing a database manager class inside my app, the main reason is to join a local 3 databases

Although the return function is not working, I know that the query brings back the rows, but when it is returned by the class, then 0 is 0. What am I missing? The public MySqlDataReader localfetchrows (string query, list & quot; MySqlParameter & gt; dbparams = null) {use (var conn = connectLocal ()) {Console.WriteLine ("local connecting:" + Conn.ServerVersion); MySqlCommand sql = conn.CreateCommand (); Sql.CommandText = Query; If (dbparams! = Null) {if (dbparams.Count> 0) {sql.Parameters.AddRange (dbparams.ToArray ()); }} MySqlDataReader Reader = sql.ExecuteReader (); Console.light line ("Reading data:" + Reader. HSRO + Reader, Filtkount); Return reader; Use / * (MySqlCommand sql = conn.CreateCommand ()) {sql.CommandText = query; If (dbparams! = Null) {if (dbparams.Count> 0) {sql.Parameters.AddRange (dbparams.ToArray ()); }} MySqlDataReader Reader = sql.ExecuteReader (); Console.light line ("Reading data:" + Reader. HSRO + Reader, Filtkount); Sql.Parameters.Clear (); Return reader; } * /}}

code for getting more results

  query = @ "Select JobTypeid, title from job type where active = 'y' order ASC by title "; //parentfrm.jobtypes = db.localfetchrows (query); Var rows = db.lokpatachra (query); Console.light line ("reading data:" + rows, smile + rows, firewalls); While reading the rows () ()) {}   

these scripts come back to:

  Local connecting: Reading 5.5.16 data: True2 reading data By using   

/ Code>

You are placing the connection inside a content, thus leaving the connection closed and disposed after reaching this line:

  return reader;   

In other words, when the caller gets back to reader , you have closed the database connection and can not fetch the rows to read the rows The connection should be open on

Comments