Query result displayed in a textbox instead datatable?

Query result displayed in a textbox instead datatable?

Postby 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!!
Communi
 

Postby 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();
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby 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?
Communi
 

Postby 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();
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby Communi » Mon 19 Jun 2006 12:38

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

Postby Alexey » Wed 21 Jun 2006 06:50

You are welcome
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for MySQL