660 likes | 915 Views
Ado.net fundamentals. Beginning asp.net 3.5 in c# . What is ADO.net. ADO.NET is the technology that .NET applications use to interact with database. Data binding is a powerful and practical feature Not easy, must have solid grasp of ADO.NET fundamentals. Understanding data management.
E N D
Ado.net fundamentals Beginning asp.net 3.5 in c#
What is ADO.net • ADO.NET is the technology that .NET applications use to interact with database. • Data binding is a powerful and practical feature • Not easy, must have solid grasp of ADO.NET fundamentals
The role of the database • Adding database to VS2013
Two groups of classes • Contain and manage data • DataSet, DataTable, DataRow, and DataRelation • Generic • Connect to specific data source • Connection, Command, and DataReader • Data providers
Data provider classes • Data classes can’t accomplish much • Data access is needed see table below
Direct data access • The easiest to connect to the database • Steps • Create Connection, Command, and DataReader objects. • Use the DataReader to retrieve information from the database, and display it in a control on a web form. • Close your connection. • Send the page to the user. At this point, the information your user sees and the information in the database no longer have any connection, and all the ADO.NET objects have been destroyed. To add or update information, follow these steps: • Create new Connection and Command objects. • Execute the Command (with the appropriate SQL statement).
Namespaces needed using System.Data; using System.Data.SqlClient;
Creating a connection • SQL Server through the OLE DB provider • Using SqlConnection object from the SQL Server
The Connection String • Data source – name of the server • Initial catalog – name of the database • Integrated security – using Windows user account, SSPI (security support provider interface) or SQL server user id and password • Connection Timeout – how long your code will wait before generating an error
Storing the connection string • Using a constructor • Store in web.config