Mysql query

Last Reply on Jul 25, 2013 04:54 AM By ashusingh

Posted on Jul 25, 2013 04:35 AM

@ mudassar , @ashusingh

I have an "Id" filed in MySqlDB "sensor_info"table, based on this id, i have to execute a query for: select the MAX id and display related messages on label according to that maximum id.

how to get this using DataManager in Mysql.

here is my query:-

string query2 = "select MAX(Id) from sensor_info";

now how i display message on label according to above "Id"(i have to choose max id) which is coming from database.

please reply.

Posted on Jul 25, 2013 04:54 AM

Hi @Priyanka12,

I have made small snippet.Just have a look.

Please modified the sql query as per your need.

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString1"].ConnectionString);
                SqlCommand cmd = new SqlCommand("SELECT MAX(EmployeeID) FROM Employees", con);
                con.Open();
                this.lblMessage.Text = "Your Id is:" + cmd.ExecuteScalar().ToString();
                con.Close();

 

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html