MySqlDataReader always Returning False even though data is there In Asp.net

Povar

New Member
Hii Guys !!! I made one C# class and one handler in Asp.net..In My C# file I made a function which is as Below:\[code\]public MySqlDataReader Consulta(String sql){ String error=""; try { string connectionString = "Server=*****;Port=3306;Database=db;UID=*****;Pwd=****;pooling=false"; MySqlConnection conn; conn = new MySqlConnection(connectionString); conn.Open(); //string s = "select empid,empname,authcode from authcode"; MySqlCommand cmd = new MySqlCommand(sql,conn); //cmd.CommandText = s; cmd.ExecuteNonQuery(); rs =cmd.ExecuteReader(); } catch (Exception e) { //error = e.getMessage(); } return (rs);}\[/code\]In My handler File i am calling this function here is my code...\[code\]MySqldataReader rs = conexiondb.Consulta(strQuery);total = conexiondb.countRec("price", "processeddata_table");string json;json = json + "{\n";json = json + " \"page\":\""+intpage+"\",\n";json = json + "\"total\":"+total_pages+",\n";json = json + "\"records\":"+total+",\n";json = json + "\"rows\": [";rc =false;while(rs.Read()){ if(rc){ json = json + ","; } json = json + "\n{"; json = json + "\"price\":\"" + Convert.ToInt32(rs["price"]) + "\","; json = json + "\"cell\":[" + Convert.ToInt32(rs["price"]) + ""; json = json + ",\"" + Convert.ToString(rs["username"]) + "\""; json = json + ",\"" + Convert.ToString(rs["ordinal"]) + "\""; json = json + ",\"" + Convert.ToString(rs["authcode"]) + "\""; json = json + ",\"" + Convert.ToString(rs["extension"]) + "\""; json = json + ",\"" + Convert.ToString(rs["trunk"]) + "\""; json = json + ",\"" + Convert.ToString(rs["dialnumber"]) + "\""; json = json + ",\"" + Convert.ToString(rs["dialdate"]) + "\""; json = json + ",\"" + Convert.ToString(rs["dialtime"]) + "\""; json = json + ",\"" + Convert.ToString(rs["duration"]) + "\""; json = json + ",\"" + Convert.ToString(rs["destination"]) + "\""; json = json + ",\"" + Convert.ToString(rs["price"]) + "\""; json = json + ",\"" + Convert.ToString(rs["toc"]) + "\"]"; json = json + "}"; rc=true;}json = json +"]\n";json = json +"}";HttpContext.Current.Response.Write(json);\[/code\]But datareader is not reading the records it is always Returning false.Plz guys Help me to sort the problem .
 
Back
Top