Register Page In ASP.Net By Using C# code
------------------------------------C# Code----------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"data source=saibaba-pc\server; database=Genreal; integrated security=SSPI");
//integrated security=SSPI means only for windows authentication
con.Open();
string username, password, mailid, phoneno;
username=TextBox1.Text;
password=TextBox2.Text;
mailid = TextBox3.Text;
phoneno= TextBox4.Text;
string sqlinsert;
sqlinsert = "insert into registration(username,password,mailid,phoneno) values('" + username + "','" + password + "','" + mailid + "'," + phoneno + ")";
SqlCommand cmd = new SqlCommand(sqlinsert,con);
cmd.ExecuteNonQuery();
Label5.Text = "datails are saved";
// con.Close();
}
}
0 comments:
Post a Comment