datareader

Datareader returns no results in VS yet Stored Procedure returns multiple result sets in Sql Server

落爺英雄遲暮 提交于 2019-12-10 13:50:02
问题 I am having trouble retrieving results from my datareader in visual studio 2008. I have several stored Procs in the same database. I am able to retrieve values from those that dont receive input parameters. However, when i use the executreReader() method on a stored proc with input parameters i get an empty datareader. Upon examining the result collection the message "IEnumerable returned no results" appears. I am baffled as I can execute the stored procs within sql server and return result

There is already an open DataReader … even though it is not

帅比萌擦擦* 提交于 2019-12-10 13:24:12
问题 Note: I've went through millions of questions when the issue is not disposing the reader/connection properly, or when the error is because of badly handled lazy loading. I believe that this issue is a different one, and probably related to MySQL's .NET connector. I'm using MySQL server (5.6) database extensively through its .NET connector (6.8.3). All tables are created with MyISAM engine for performance reasons. I have only one process with one thread ( update: in fact, it's not true, see

How to add columns to DataReader

…衆ロ難τιáo~ 提交于 2019-12-09 18:58:30
问题 My goal is to retrieve data from a data source, add some metadata to it and insert it to another target. The target has schema with four more columns then the source (calculated columns). I am using SqlBulkCopy , which requires a reader with all columns (including the 4 calculated). Is there a way to add columns to the DataReader manually? or if it's not possible what alternatives i have for the data insertion? 回答1: I needed to do this, and also have the ability to make columns based on other

Performance issues to iterate results with C# SQLite DataReader and attached database

天大地大妈咪最大 提交于 2019-12-08 15:59:05
问题 I am using System.Data.SQLite and SQLiteDataReader in my C# project. I am facing performance issues when getting the results of a query with attached databases. Here is an example of a query to search text into two databases : ATTACH "db2.db" as db2; SELECT MainRecord.RecordID, ((LENGTH(MainRecord.Value) - LENGTH(REPLACE(UPPER(MainRecord.Value), UPPER("FirstValueToSearch"), ""))) / 18) AS "FirstResultNumber", ((LENGTH(DB2Record.Value) - LENGTH(REPLACE(UPPER(DB2Record.Value), UPPER(

Can I reset and loop again through MySqlDataReader?

故事扮演 提交于 2019-12-08 05:50:41
问题 I have a MySqlDataReader object, with the result of this query : SELECT warehouse, leasing, transportation, maintenance, manpower FROM retail WHERE zone = 'Central' GROUP BY warehouse And then I loop through the DataReader once, while (r2.Read()) { strXml.AppendFormat("<set label = '{0}'></set>",r2["warehouse"].ToString()); } And now I want to loop through it again...!! I know that DataReader is only a 'forward-only' object.. But is there any other solution for me here ? I'm asking, is there

MySqlDataReader: DataTable.Fill(reader) throws ConstraintException

霸气de小男生 提交于 2019-12-07 08:10:37
问题 I have two tables orders and orderdetails table orders (PK = id, UNIQUE index on orderno) |id|orderno| | 1|1000 | | 2|1001 | table orderdetails (PK = id) |id|orderid|item|qty| | 1| 1|ABC | 3| | 2| 1|XYZ | 4| Now I want to query the data with: SELECT o.orderno, od.item, od.qty FROM orders o INNER JOIN orderdetails od ON o.orderno = od.order which returns: |orderno|item|qty| |1000 |ABC | 3| |1000 |XYZ | 4| However If I use the following code to load the result into a DataTable it fails: var

Intermittent System.IndexOutOfRangeException when reading a field from IDataReader

↘锁芯ラ 提交于 2019-12-07 07:23:36
问题 I have a very weird problem in code that I would not expect to ever fail. It is a website with some traffic but not that huge based on AspDotNetStoreFront. Site intermittently crashes when trying to read a database field from a reader. This happen on various places on the website. An example of such code is below on the line with object pValue = rs["PropertyValueString"]; private Dictionary<string, object> GetPropertValuePairs(string userName) { string query = string.Format("select

Using SqlDataReader for filling List<T> in c#

时光总嘲笑我的痴心妄想 提交于 2019-12-07 02:45:25
I have a class like below, class Student { public string Name {get; set;} public string Surname {get; set;} public int Age {get; set;} public string Address {get; set;} } And I have a MySql table with 50,000 records. The Structure of the table is like below, ID NAME SURNAME AGE ADDRESS 1 Joe Philip 20 Moscow 2 Misha Johny 25 London ... And I have a C# code, List<Student> students = new List<Student>(); string sql = "SELECT name,surname,age,address FROM Students"; command.CommandText = sql; MySqlDataReader reader = command.ExecuteReader(); while(reader.Read()) { Student st = new Student(); st

Can I reset and loop again through MySqlDataReader?

喜你入骨 提交于 2019-12-06 16:50:06
I have a MySqlDataReader object, with the result of this query : SELECT warehouse, leasing, transportation, maintenance, manpower FROM retail WHERE zone = 'Central' GROUP BY warehouse And then I loop through the DataReader once, while (r2.Read()) { strXml.AppendFormat("<set label = '{0}'></set>",r2["warehouse"].ToString()); } And now I want to loop through it again...!! I know that DataReader is only a 'forward-only' object.. But is there any other solution for me here ? I'm asking, is there any any efficient way to hold data other than MySqlDataReader ? You can use below : using

Regarding a small confusion about DataReader

帅比萌擦擦* 提交于 2019-12-06 14:34:47
问题 I was reading about DataReader and found a statement about DataReader which is not clear. here it is DataReader fetches the records from database and stores in the network buffer and gives whenever requests. It releases the records as query executes and do not wait for the entire query to execute. Hence very fast as compare to the DataSet which releases the data after loading all the data in memory. 1) it says that DataReader fetches the records from database and stores in the network buffer?