shameer pv

shameer pv

  • NA
  • 55
  • 60k

need help in database connectivity in c#

Aug 26 2010 7:02 AM
im beginner to c# ,asp.net and mysql
i write a program to access some data from mysql server.thats works fine
but i want to select a max value of a field. how can i access that value from data reader . i tried many ways . but...
code is given below

MySqlConnection con = new MySqlConnection();
            con.ConnectionString = "Data Source=localhost;Database= mydatabase;User ID=root;Password=vox";
            con.Open();
            string str;
            str = string.Format("select max(user_id)  from usertable");
            MySqlCommand cmd = new MySqlCommand(str, con);
            MySqlDataReader dr;
            dr = cmd.ExecuteReader();

how can i get that max value of user_id from data reader.

thanks in advance


Answers (1)