50 likes | 59 Views
CSC 298. ADO .NET. ADO .NET . A data access technology that maps very well to the world of the web (disconnected architecture) data is retrieved from the database and cached on the local machine (similar from a web session). Two providers.
E N D
CSC 298 ADO .NET
ADO .NET • A data access technology that maps very well to the world of the web (disconnected architecture) • data is retrieved from the database and cached on the local machine (similar from a web session)
Two providers • SQL server .NET provider to interface with Microsoft SQL servers • all of the code is managed by the CLR • namespace System.Data.SqlClient • OLE DB .NET for other data base servers • goes through unmanaged code (not as efficient) • namespace System.Data.OleDb
Connecting to a database • Use a Connection object, e.g. OleDbConnection c; c = new OleDbConnection( "provider = Microsoft.Jet.OleDb.4.0; " + @"data source = C:\Northwind.mdb"); • Don't forget to open the connection • c.open();
Communicating with the DB queries DB DataAdapter DataSet updates • Use a DataSet and a DataAdapter (e.g. OleDbDataAdapter) • Displaying the data: use a DataGrid