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
1
vote
2 answers

How to execute two separate queries from one DBCommand object?

I have the following code that tries to get records from two different tables and then add them to the particular comboboxes. Only the first query works and the second one is ignored. Try sqlConn = New MySqlConnection connStr =…
Student
  • 432
  • 2
  • 10
  • 30
1
vote
4 answers

HasRows property in MySqlDataReader C# always return true value?

In my code when I debug using Visual Studio C# I noticed that although there are no rows in the query : select MAX(idSalesJournal) as maxId from accountingsystemdb.salesjournal" the dr.HasRows property always returns TRUE. When I continue…
1
vote
1 answer

Mysql Exception on ExecuteReader

Well i had a weird exception on my program so i tried to replicate it to show you guys, so what i did was to create a table with id(int-11 primary), title(varchar-255) and generated 100k random titles with 40 chars lenght, when i run my method that…
Incognito
  • 435
  • 1
  • 7
  • 23
1
vote
1 answer

DataReader: What is the "real" property of r("somecolumn")?

I am using a MySqlDataReader and a Sqlite.SqliteDatareader. For both, I can access the value of a column like this: Do While r.Read dim sSomeString = r("SomeColumn") (...) I think that r("SomeColumn") internally resolves to a…
tmighty
  • 10,734
  • 21
  • 104
  • 218
1
vote
2 answers

IsDBNul with string

I try to use currentOrder.PONumber = (reader.IsDBNull("PONumber") ? "Geen klantreferentie" : reader.GetString("PONumber")); and I have the following errors: The best overloaded method match for 'System.Data.Common.DbDataReader.IsDBNull(int)'…
Marten
  • 1,376
  • 5
  • 28
  • 49
1
vote
9 answers

Checking the number of rows returned from MySQL Data Reader

I am currently working on an C# project and I am trying to get the number of rows returned from MySQL Data Reader. I know there is no direct function so I am trying to write my own. In the function, I pass it the MySQLDataReader object and then…
Boardy
  • 35,417
  • 104
  • 256
  • 447
1
vote
2 answers

Index was outside the bounds of the array, but i can't see the error

int n =Count("SELECT COUNT(*) FROM information_schema.SCHEMATA");; //return 6 TreeNode[] db_name = new TreeNode[n]; MySqlCommand cmd = new MySqlCommand("show databases", connection); MySqlDataReader dataReader =…
Bruce Rox
  • 21
  • 5
1
vote
1 answer

GetBytes() can only be called on binary or GUID columns

I'm developing an app in C# with .NET and MySQL database. I need to be able to insert and retrieve images in and out of the database and I have a column named 'Image' of type LONGBLOB for that purpose. The insertion goes well but when I try to…
Igor
  • 1,532
  • 4
  • 23
  • 44
1
vote
1 answer

MySqlDataReader in C# has no rows

I'm trying to develop a little user-user messaging system in C# (my first C# app) using a mysql database. I know best practice would be to use something like EF for working with the database, but I'm writing this the "stupid" way just to get…
Ortund
  • 8,095
  • 18
  • 71
  • 139
1
vote
4 answers

mysql data read returning 0 rows from class

I am implementing a database manager class within my app, mainly because there are 3 databases to connect to one being a local one. However the return function isn't working, I know the query brings back rows but when it is returned by the class it…
Neo
  • 2,305
  • 4
  • 36
  • 70
0
votes
1 answer

C# MySqlDataReader and Timer Sync issue

Im polling a view using a timer but after a few rounds of the poll the output goes out of sync. Doesnt matter what the polling time it seems also. Any ideas what is wrong with my code I'm wondering is it an issue with my timer and or is it the…
0
votes
1 answer

MySqlDataReader : I close the connection but get : There is already an open DataReader associated with this Connection which must be closed first

private void startPoll() { System.Diagnostics.Debug.WriteLine("dbForm created"); timer = new Timer(int.Parse(Properties.Settings.Default.DbPoll) * 1000); // ElapsedEventHandler OnEventExecution = null; …
0
votes
0 answers

How can I retrieve the correct value of a MySQL Time Column in C# using the MySqlDataReader

I am currently working on a method, which is supposed to retrieve data from a MySQL Database and build an Insert-Statement with the retrieved data. So far I was able to get the values of all columns, except for one which type is time. I have been…
0
votes
1 answer

MySQL connection seems to be only reading first query

I'm working on a C# project and until now I haven't had any difficulties whatsoever, the problem is while coding a simple login form. Here's the code for it: MySqlConnection con = new MySqlConnection(); MySqlCommand com = new…
Zarcero
  • 3
  • 3
0
votes
0 answers

MySqlDataReader Hasn't Row But Query has data

My Query in PHPmyadmin has result but in C#, a.read() returns no data. string query = "SELECT answer FROM tbl WHERE level = " + level + " AND subject = '" + subject[i] + "';"; MySqlCommand command = new MySqlCommand(query,…
seyed
  • 71
  • 1
  • 7