Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
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();
     }
Posted
Comments
Jibesh 24-Dec-12 23:07pm    
why are you posting the same question again and again. I have found 2 Query with same questions

http://www.codeproject.com/Questions/514610/howplustopluswriteplusthispluscode-3f
http://www.codeproject.com/Questions/514683/c-23pluscodingplusproblemplusthatplusiplusneedplus

and both of them are marked as resolved why? If the answer didnt satisfy your query you can ask more question in the same thread itself. you can always use the 'Improve Question' link at the right bottom of your question to modify your question.

do not overpopulate CP with redundant questions
Sergey Alexandrovich Kryukov 25-Dec-12 0:02am    
How is this code related to the question? :-)
—SA

1 solution

It could be something like
C#
myButton.Click += (sender, eventArgs) => { TheMethodToExecute(/* ... */); }


—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900