Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- using System.Configuration;
- public partial class Index : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if(IsPostBack)
- {
- SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MemberInfoConnectionString"].ConnectionString);
- conn.Open();
- string checkuser = "select count(*) from SystemMemberInfo where Username="+ TextBoxUserName.Text +"'";
- SqlCommand com = new SqlCommand(checkuser, conn);
- int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
- if (temp == 1)
- {
- Response.Write("User already Exists");
- }
- conn.Close();
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MemberInfoConnectionString"].ConnectionString);
- conn.Open();
- string insertQuery = "insert into SystemMemberInfo (Username,Email,Password,Minecraft Username) values (@Uname ,@email ,@password ,@mcuname)";
- SqlCommand com = new SqlCommand(insertQuery, conn);
- com.Parameters.AddWithValue("@Uname", TextBoxUserName.Text);
- com.Parameters.AddWithValue("@email", TextBoxEmail.Text);
- com.Parameters.AddWithValue("@password", TextBoxPassword.Text);
- com.Parameters.AddWithValue("@mcuname", TextBoxMcUserName.Text);
- com.ExecuteNonQuery();
- Response.Redirect("WebsiteSystem.aspx");
- Response.Write("Registration is successful.You can login now." );
- conn.Close();
- }
- catch(Exception ex)
- {
- Response.Write("Error:"+ex.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement