Friday 29 April 2016

Insert Database and create a connection with database in Asp.net with C#

How to Insert Database in Asp.Net with C#?
1). First Open the visual Studio 2008.















2). Click on Website and Select “ASP.NET Web Site” and Select a “Visual C#” Language and Set the Location and Press “ OK ”.

















3).  Open "Solution Exporer" and Select Website and right click and Add New Item.


















4). Select “SQL Server Database” Change a Database Name and Press Add Button.
















5). Click On Yes button.















6). Open “Server Explorer” You can see the Database.

















7). Right Click and a “Add New Table”.


















8). Set the “Column name ”, “Datatype” and “Allow Nulls” and press CTRL+S and set the Table name and Press “OK” button.


















9). You can see the table in “Server Exporer”




















=> we can use a using System.Data.SqlClient name space for sql database.

we can use a using System.Data.OledDb name space for Oledb database.
we can use a using System.Data.ODBC name space for ODBC database.

we can create a connection object for establish a connection of database.

Coading 

public void conn()
{
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString);
cn.open();
}
in this coading the database connection is set a connetion string dynamic.


No comments:

Post a Comment