Sunday, 30 September 2012

DataBase Connectivity

Database is used to store the informations.
for example . User Registration or Sign Up Page......
take labels , textboxes ,button ,fileupload and a image control in your form according to your need....
and take validation controls ..
arrange like this...


now in the coding window
first of all add the namespace "using System.Data.SqlClient;"which contains all the methods n functions related to sql.

now in the class above the page load event writes  the code

 SqlConnection con = new SqlConnection("server=VAIBHAV;database=exam;uid=sa;password=1234");
it is used to create the connection between .net and the database..
server=name of your server.
databse=name of your database.
uid=user id.
password=password of your server.

in the button click event write the code



 con.Open();=to open the connection.
con.Close();=to close the connection.
sqlcommand=write the sqlquerry you want to be execute.
 cmd.ExecuteNonQuery();=it execute the querry.
remaining part of sqlcommand

it is the work of asp.net..now come on the sql server
in the sqlserver make the database..
like this...column name,and the data stores in the database...





No comments :

Post a Comment