Database connectivity
l There are two methods used in database connectivity .
1. Configuration method
2. Code method
1. Configuration method :-
Step 1: include database libariaies .
Step 2 :create database object(before pageload event ).
I. Connection object :- it represent the database location (path/connection string ) .
II. Command object:- representing all the query ex.DDL,DML,CURD OPEATION.
III. DataReader object :- only used for select query (which is only used to reading the data).
Step 3 . Break the page load event (inside the page load).
2. Code method :-
Step 1 :- open database
Step2 :- give command (Query)
Step 3:- execute command .
How to write the code .
Var <-------------- info
Object (var)
Ex:- string k=”insert ”;
Com=new sqlcommand (k);
//step 1 open databse
string path = "";
con = new SqlConnection(path);
con.Open();
// step 2 apply command (query)
string insert = "insert";
com = new SqlCommand(insert,con);
// step 3 execute command
com.ExecuteNonQuery();
Comments
Post a Comment