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:
- <connectionStrings>
- <add name="con" connectionString="Data Source=;Initial Catalog=;User ID=;Password="/>
- </connectionStrings>
- <system.web>
- <compilation debug="true" targetFramework="4.0" />
- </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:
- public partial class **** : System.Web.UI.Page
- {
- string sqlcon = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
-
- SqlConnection con = new SqlConnection(sqlcon);
- con.Open();
- SqlCommand cmd= new SqlCommand("insert into OnlineForm values('"+fname.Text+"','"+lname.Text
- +"','"+dob.Text+"','"+gender.Text+"','"+address.Text+"')",con);
- cmd.ExecuteNonQuery();
- con.Close();
- }
Finally execute the program by f5. Your page will be executed. successfully.