Creating/Inserting DATABASE in .NET Framework
So are you ready to learn to learn how to create database for
your websites, portals in simple and easy step for a lots of application…?
Well in this article am going to explain step wise procedure of creating database for your web purpose like-
Well in this article am going to explain step wise procedure of creating database for your web purpose like-
- Sessions
- User Interaction Page
- Registration Page
- Contact info Page
etc.
Procedure
Step:
1
Coding
in Class File Page (.CS)
We need to code in .CS file first of all for coding. First of
all we need to attempt to add a special file type (class) to an ASP.NET
website. In general to use this type of
item in your site, you should place it in ‘App_Code’ folder.
Follow these steps:
- Open a empty ASP.NET website
- Click on SOLUTION EXPLORER
- Then right click on C:\...\website1
- Add a new item
Follow these steps:
- Open a empty ASP.NET website
- Click on SOLUTION EXPLORER
- Then right click on C:\...\website1
- Add a new item
- Select
Class file from there and add
[A new window like this will get open]
[A new window like this will get open]
In this page, code according to this:
// APP_Code/Class1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
/// <summary>
/// Summary
description for Class1
/// </summary>
public class Class1
{
public SqlConnection con;
public SqlConnection con;
Public void show()
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["ABC"].ConnectionString);
con.Open();
}
}
Step:
2
Coding | Default Page
Coding | Default Page
Now we need to code in default page, you can find this page
in your website named as:
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
{
Class1 o = new
Class1();
protected void
Page_Load(object sender, EventArgs e)
{
o.show();
}
protected void
Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd
= new SqlCommand("insert into Reg values('" + TextBox1.Text +
"','" + TextBox2.Text + "')", o.con);
cmd.ExecuteNonQuery();
Response.Redirect("Default2.aspx");
}
}
______________________________________________________
for more technical stuff, please visit:
______________________________________________________