什么是Button单击以执行该方法的代码 [英] what would be the code for the Button click to execute the method

查看:81
本文介绍了什么是Button单击以执行该方法的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public static string Newmember(string mname, int password, string email)
 {

     SqlConnection con = new SqlConnection(Database.ConnectionString);
     try
     {
         SqlCommand cmd = new SqlCommand("select isnull(max(mid),0)+1 from members", con);
         int mid = (int)cmd.ExecuteScalar();

         cmd.CommandText = "insert into members values(@mid,@mname,@password,@email)";
         cmd.Parameters.Add("@mid", SqlDbType.Int).Value = mid;
         cmd.Parameters.Add("@mname", SqlDbType.VarChar, 50).Value = mname;
         cmd.Parameters.Add("@password", SqlDbType.Int).Value = password;
         cmd.Parameters.Add("@email", SqlDbType.VarChar, 40).Value = email;
         cmd.ExecuteNonQuery();
         HttpContext.Current.Trace.Write("Member has been added successfully with ID = " + mid +"\n "+"your name is" +mname +" " +"your password is"+password+" "+"your email is "+ email);

     }
     catch (Exception ex)
     {
         HttpContext.Current.Trace.Write("error" + ex.Message);

     }
     finally
     {
         con.Close();
     }

推荐答案

它可能类似于
myButton.Click += (sender, eventArgs) => { TheMethodToExecute(/* ... */); }





-SA


这篇关于什么是Button单击以执行该方法的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆