execute select query in one line?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
xterm
Posts: 9
Joined: Tue 15 Nov 2005 13:24

execute select query in one line?

Post by xterm » Mon 28 Nov 2005 17:28

Is there a way to do something like this MySql.Data.MySqlClient.MySqlHelper.ExecuteScalar(sqlConn, SQL) with mysqldirect .net 3.05 as i do it with Mysql .Net Dataprovider? I need it because i want to get the max value of a specific field in my DataBase.

Sorry for my English
Please Help

Serious

Post by Serious » Tue 29 Nov 2005 13:16

You can use MySqlCommand.ExecuteScalar() method to retrieve single value from query.

Code: Select all

MySqlCommand command = new MySqlCommand("select max(deptno) from dept", connection);
int maxDeptno = (int)command.ExecuteScalar();

xterm
Posts: 9
Joined: Tue 15 Nov 2005 13:24

Post by xterm » Tue 29 Nov 2005 19:10

Thank you very much.I have bought 2 weeks ago mysqldirect .net and i am very pleased.Keep the good try!!!

Post Reply