Simple Application Form in ASP.NET

Steps To Do The Project:

  • First open vb2013->Goto website->ON web location create a folder of your name and project for e.g. (D:\Viswanath\sample2\WebSite1).

  • It will create a project and a blank screen will appear. Afterwards goto WEBSITE->ADDNEW ITEM->WEBFORMS->and in default.aspx -give a suitable name and ADD.

  • A design and source code form will be opened under the given name.

  • Now go to design->Click View in toolbar->and select toolbox->it will appear with several tools for designing your web page and with textboxes, labels and buttons CREATE A SIMPLE APPLICATION form.

And you have to create a database for inserting values for that you have to create a table in database:

  • CREATE DATABASE dbname:

      CREATE TABLE Persons
      (
         PersonID int,
         LastName varchar(255),
         FirstName varchar(255),
         Address varchar(255),
         City varchar(255)
      );

  • And connect the table by Solution explorer->webconfig-> and insert the coding:
    1. <connectionStrings>  
    2.    <add name="con" connectionString="Data Source=;Initial Catalog=;User ID=;Password="/>  
    3. </connectionStrings>  
    4. <system.web>  
    5.    <compilation debug="true" targetFramework="4.0" />  
    6. </system.web>  
    After completing goto server explorer and then connect the database. Right click dataconnection-> connect with ur database name.

  • And in submit button give the coding:

    1. public partial class **** : System.Web.UI.Page  
    2. {   
    3.    string sqlcon = ConfigurationManager.ConnectionStrings["con"].ConnectionString;   
    4.   
    5.    SqlConnection con = new SqlConnection(sqlcon);  
    6.    con.Open();  
    7.    SqlCommand cmd= new SqlCommand("insert into OnlineForm values('"+fname.Text+"','"+lname.Text  
    8.    +"','"+dob.Text+"','"+gender.Text+"','"+address.Text+"')",con);  
    9.    cmd.ExecuteNonQuery();  
    10.    con.Close();  
    11. }

Finally execute the program by f5. Your page will be executed. successfully.