Hello friends !! Today i am just going to expain about data provide in the ado.net which is as given below:
DataProvider !!
DataProvider:
- The main task of data provider is provide the data.
- DataProvider is used for connecting database executing command and retrieving result also.
- DataProvider is a software component enabling an ADO.NET consumer to interact with a data source.
- DataProvider make the connection with data source.
- There are some DataProvider for example MYSQL (STRUCTURE QUERY LANGUAGE), OLEDB (OBJECT LINKING EMBEDED DATABSE), ODBC (OBJECT DATABASE CONNECTIVITY).
DataProvider has main object which are explain as given below:
- SqlConnection
- SqlCommand
- Sqldatareader.
- SqlDataAdepter
Sqlconnection:
- Sqlconnection is an object used to make connection with database.
- We make instance of sqlconnection which is take connection string as argument and pass the value to the constructor statement.
There are two type of connection we make which is as given below :
1. Open();
2. Close();
Open();: The Open(); method we used for open the database connection.
Close();The Close(); method we used for Close the database connection.
Syntax:
SqlConnection con = new SqlConnection ("data source=.; initial catalog=project2; integrated security=true");
Note:
data source=.; (this tell your server name)
. (Dot means your current server name)
Initial catalog =project2; (tell your database name)
(Project2 is a database name)
Integrates security=true (it tell you that you are login in the sql server with window authentication)
Note: if you login with Sql server authentication then you have to give here id and password instead of integrated security =true as given below:
User Id=sandeep;
Password=soni;
The code screen will you see as given below:
I hope this post will help you ..
If you've some query regarding to this article then post you comment .Your comment will be appropriate..
0 comments:
Post a Comment
Hey thanax alot to comment i will revert you back soon...