How to make Register page in asp.net Using C# and Ms sql 2014

Hello Guys In This Post We will Learn about How to make Register page in asp.net Using C# and Ms sql, do you want to make Register page in asp.net with Visual Studio and MS SQL managemnet Studio 2014.

How to make Register page in asp.net Using C# and Ms sql

To do this process you must have Visual Studio and Microsoft sql Management Studio, you can use any version of it. 

For Visual studio

  1.  Visual Studio 2008
  2.  Visual Studio 2010
  3.  Visual Studio 2012
  4.  Visual Studio 2013
  5.  Visual Studio 2017

For Microsoft sql Management Studio

  1.   Microsoft sql Management Studio 2008
  2.   Microsoft sql Management Studio 2012
  3.   Microsoft sql Management Studio 2014

To do this process, we will be using some steps like creating a database, creating connections and commanding So let's start.

1st Step : Create Database and Table in MS SQL

CREATE TABLE tblregister(
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](100) NULL,
    [email] [nvarchar](100) NULL,
    [password_] [nvarchar](100) NULL,
    [address] [nvarchar](100) NULL
    );

2nd Step : Create Connection string (Web.Config)

We need to create connection string in Web.Config File to connect sql database in Visual Studio.

<?xml version="1.0"?>

<configuration>

  <connectionStrings>
     <!--<add name="connect" connectionString="Data Source=SARTHAK-PC;Initial Catalog=table_name;Integrated Security=True" providerName="System.Data.SqlClient"/>-->
  </connectionStrings>
</configuration>

3rd Step : Create Register page Design (Default.aspx)

<asp:TextBox ID="txtname" placeholder="Name" required="required" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="txtemail" placeholder="Email" required="required" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="txtpassword" placeholder="Password" required="required" TextMode="Password" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="txtaddress" placeholder="Address" required="required" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btnregister" runat="server" Text="Register" OnClick="btnregister_Click" />

4th Step : Write NameSpace in code behind C#  (Default.aspx.cs)

using System.Configuration;
using System.Data.SqlClient;

5th Step : Import Connection String in C# code (Default.aspx.cs)

public partial class _Default : System.Web.UI.Page
{
    string mystring = ConfigurationManager.ConnectionStrings["myconstring"].ConnectionString.ToString();
    protected void Page_Load(object sender, EventArgs e)
    {

    }

}

6th Step : Write code on Buttion click Event (Default.aspx.cs)

protected void btnregister_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(mystring);
        con.Open();
        string query = "insert into tblregister (Name,email,password_,address) values ('" + txtname.Text + "','" + txtemail.Text + "','" + txtpassword.Text + "','" + txtaddress.Text + "')";
        SqlCommand cmd = new SqlCommand(query,con);
        cmd.ExecuteNonQuery();
        Response.Write("<script>alert('Succeesfully Registered')</script>");

    }

Final Step : Whole code of Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    string mystring = ConfigurationManager.ConnectionStrings["myconstring"].ConnectionString.ToString();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnregister_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(mystring);
        con.Open();
        string query = "insert into tblregister (Name,email,password_,address) values ('" + txtname.Text + "','" + txtemail.Text + "','" + txtpassword.Text + "','" + txtaddress.Text + "')";
        SqlCommand cmd = new SqlCommand(query,con);
        cmd.ExecuteNonQuery();
        Response.Write("<script>alert('Succeesfully Registered')</script>");

    }
}

Register page in asp.net Using C# Video Tutorial

 

Register page in asp.net C#

i hope you understand better if you have any query then you need to comment or ask question thanks a lot.