Query result displayed in a textbox instead datatable?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Communi

Query result displayed in a textbox instead datatable?

Post by Communi » Mon 19 Jun 2006 11:22

How can I display a result of a query in a textbox instead of a datatable or a grid? The result is only a number (Select SUM()...) that should be displayed in a formatted textbox.
Should I use the MySqlText object or is there a quick solution for this?

Thanks!!

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Mon 19 Jun 2006 11:29

You may use MySqlDataReader object to return the number
(Select SUM()...)
and then assign that number to a TextBox like this:

Code: Select all

textBox1.Text = reader[0].ToString();

Communi

Post by Communi » Mon 19 Jun 2006 11:55

This doesn't work :-(
There comes the message: "The value of CoreLab.MySql.MySqlDataReader cannot converted to a string"
Whats wrong there?

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Mon 19 Jun 2006 12:17

I see this error first time.
Try to use the following statement:

Code: Select all

textBox1.Text = mySqlCommand1.ExecuteScalar().ToString();

Communi

Post by Communi » Mon 19 Jun 2006 12:38

Yes, now it works! Thank you very much, you make a really good job!!!!

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Wed 21 Jun 2006 06:50

You are welcome

Post Reply