Questions tagged [mysqldatareader]

Reads a forward-only stream of rows from a MySQL database.

Reads a forward-only stream of rows from a MySQL database. To create a MySqlDataReader, you must call the ExecuteReader method of the MySqlCommand object, rather than directly using a constructor.

101 questions
63
votes
15 answers

Error: select command denied to user ''@'' for table ''

In my website, I am using MySQL database. I am using a webservice where in I do all my database related manipulations. Now In one of the methods of that webservice, I get the following Error. select command denied to user ''@''…
Parth Bhatt
  • 19,085
  • 27
  • 131
  • 216
19
votes
4 answers

Using MySQLConnection in C# does not close properly

Final solution: The connection was added to the connection pool. So I closed it, but it still remained physically open. With the ConnectionString Parameter "Pooling=false" or the static methods MySqlConnection.ClearPool(connection) and…
Skalli
  • 2,597
  • 3
  • 25
  • 36
19
votes
9 answers

How to check for NULL in MySqlDataReader by the column's name?

How can I check for a NULL value in an open MySqlDataReader? The following doesn't work; it's always hitting the else: if (rdr.GetString("timeOut") == null) { queryResult.Egresstime = "Logged in"; } else { queryResult.Egresstime =…
rd42
  • 3,378
  • 14
  • 52
  • 67
10
votes
6 answers

MySQLDataReader retrieving Null value problem in c#

I am currently working on a C# project that will export MySQL Data. The export is for any database within the server so I am not going to know what fields and the data types that are in the table and I am not going to know if a field in the table…
Boardy
  • 31,944
  • 94
  • 238
  • 411
6
votes
6 answers

MySqlDataReader: DataTable.Fill(reader) throws ConstraintException

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…
Jürgen Steinblock
  • 26,572
  • 21
  • 100
  • 169
6
votes
5 answers

What is a more efficient way to query MySQL using C#?

Based on links around the StackOverflow site (references below), I've come up with this block of code to perform queries from my C# application to a MySQL database. using (var dbConn = new MySqlConnection(config.DatabaseConnection)) { using (var…
Frank
  • 61
  • 1
  • 3
5
votes
2 answers

MySQL datetime field query sort by hour:minute

I have a table like this: id date_time 1 2/11/2013 7:05 2 2/11/2013 7:00 3 2/12/2013 7:00 4 2/14/2013 7:00 5 2/16/2013 7:00 6 2/17/2013 7:00 7 2/12/2013 7:05 8 2/14/2013 7:05 9 2/15/2013 7:05 10 2/16/2013 7:05 11 2/17/2013…
Peter
  • 1,173
  • 5
  • 19
  • 39
4
votes
1 answer

nested data reader issue mysql c#

I have written a custom class to handle database queries to a remote and local MySQL database, however when I do a nested loop I receive the below error: MySql.Data.MySqlClient.MySqlException was unhandled Message=There is already an open DataReader…
Neo
  • 2,098
  • 4
  • 33
  • 63
3
votes
1 answer

Understanding internals of MySqlDataReader

I'd like to understand the quirks of MySqlDataReader (or IDataReader in general). Whilst researching on the internet I found many resources on how to use the MySqlDataReader, but very little about what's happening behind the scenes. I am asking…
Paul Kertscher
  • 8,484
  • 5
  • 30
  • 51
3
votes
1 answer

MySQL .Net Connector - MySqlReader.Read() returns false

I have some strange problem. I use MySQL Connector.NET but MySqlReader.Read() sometimes returns true and sometimes false. MySqlReader.HasRows is true both cases and in VisualStudio I can see that reader object hold all values. Why could that…
Joe
  • 2,481
  • 6
  • 34
  • 60
3
votes
2 answers

How to return a MySqlDataReader before the reader is closed

Okay, my code is currently: public MySqlDataReader CreateQuery(string queryString, string connectionString ) { using (MySqlConnection connection = new MySqlConnection(connectionString)) { using (MySqlCommand…
PiousVenom
  • 6,780
  • 8
  • 43
  • 83
2
votes
1 answer

MySqlDataReader GetBytes buffer issue...

I've found a curious quirk of the MySqlDataReader.GetBytes implementation and just wondering if this is well known as I can't seem to find any articles about it on the net. If you follow the code example for the SqlDataReader and apply it to the…
David
  • 1,451
  • 19
  • 32
2
votes
1 answer

C# an error in storing MySQL database contents to a List

I am getting the output that I do not want to get. I think my code is correct however there might be something I missed. C# Code: try { string mydbConnection = "datasource=localhost;port=3306;username=root;password=Greenford123;"; MySqlConnection…
2
votes
2 answers

.NET MySql does "Using" closes the datareader?

I used to close an open datareader using the try/catch/finally block: Dim dr As MySqlDataReader = Nothing Try dr = DBConnection.callReadingStoredProcedure("my_sp") Catch ex As Exception ' the caller will handle this Throw ex Finally …
vulkanino
  • 8,858
  • 6
  • 38
  • 67
2
votes
3 answers

C# DataReader error

I looked for a solution to this problem on the forum, but I didn't find one for my problem. On button click, I receive error: There is already an open DataReader associated with this Connection which must be closed first. So, I tried to close all…
dpaul1994
  • 338
  • 2
  • 15
1
2 3 4 5 6 7