hi,

plz help me how can i get the return value of mysql stored function from ASP.net with c#.
Currently i m using the following code for this purpose

string strConnect = "Data Source=" + host + ";Database=" + database + ";User ID=" + user + ";Password=" + password + ";Port=" + port;
        MySqlConnection conn = new MySqlConnection(strConnect);
        MySqlCommand cmd = new MySqlCommand("f_UserLogin", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new MySqlParameter("username", txt_user.Text));
        cmd.Parameters.Add( new MySqlParameter("pwd",txt_user.Text));
           try
            {
                cmd.Connection.Open();
                int res = cmd.ExecuteNonQuery();
                if (res > 0)
                {
                    txt_wronglogin.Text = "Success";
                }
                else
                {
                    txt_wronglogin.Text = "na pa g";
                }
            }                                
          catch (Exception ex)
          {
             txt_wronglogin.Text = ex.ToString();
          }

Thanks and Best Regards,
Nice Candy

Recommended Answers

All 2 Replies

Please suggest in what way u want to return the values

Please suggest in what way u want to return the values

in the function definition i return 1 or 0 according to my condition. now how can i execute my function and get its result that will either 1 or 0.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.