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.

107 questions
72
votes
17 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,381
  • 28
  • 133
  • 216
20
votes
4 answers

Using MySQLConnection in C# does not close properly

I try to write a class to make MySql Connections easier. My problem is, after I open a connection and close it. It is still open in the Database and gets aborted. I'm using the 'using' statement' of course, but the connection is still open and gets…
Skalli
  • 2,707
  • 3
  • 27
  • 39
20
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,584
  • 15
  • 56
  • 68
11
votes
7 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
  • 35,417
  • 104
  • 256
  • 447
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
  • 30,746
  • 24
  • 119
  • 189
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,264
  • 5
  • 20
  • 41
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,305
  • 4
  • 36
  • 70
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
  • 9,416
  • 5
  • 32
  • 57
3
votes
3 answers

Is there a way to check if column supports null values from datareader?

Columns of a table in db can store a null values (as DBNulls). Is there a way I can get this info from IDataReader or DbDataReader? using (var reader = command.ExecuteReader()) { //can I get the column info like if it supports null value if I…
nawfal
  • 70,104
  • 56
  • 326
  • 368
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,551
  • 6
  • 38
  • 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,888
  • 11
  • 47
  • 86
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,731
  • 24
  • 37
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
  • 9,074
  • 7
  • 44
  • 71
1
2 3 4 5 6 7 8