Is2215 lecture7 lecturer_ado_intro

266 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
266
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Is2215 lecture7 lecturer_ado_intro

  1. 1. DATABASES IN VISUAL BASIC.NETADO.NET
  2. 2. ADO .NET  ADO.NET is an OO framework that allows you to interact with DBs  Can use ADO.NET through code, or by using bounded controls  ADO.NET extremely flexible and efficient
  3. 3. ADO.NET  Previously applications would talk to Database using SQL  The application would be constantly connected to the DB  We still use SQL but the data is disconnected  It will connect to a database server when it needs to run a query and then disconnects immediately  ADO.NET still provides the connection oriented traditional approach.
  4. 4. Traditional Data AccessArchitecture1. Makes a Connection2. Pass some query to DB and reads result3. Pass another query to DB and reads result4. Disconnects from DB System
  5. 5. ADO.NET Disconnected Model1. Make a connection2. Pass query and gets back result3. Disconnects4. Makes connection again5. Passes another query and gets result6. Disconnects from the DB
  6. 6. ADO.NET Keeps a local virtual copy of the database in your application All of the generic classes for data access are stored in the System.Data Namespace.
  7. 7. ADO.NET ADO.NET uses managed providers to connect to databases Managed providers allow fast data streams from databases Deals with security such as database locks, passwords etc.,
  8. 8. Main Components of ADO.NETObject DescriptionConnection Creates a connection to the data sourceCommand Provides access to commands that can be executed against the data sourceDataAdapter Serves as an ambassador between your dataset and datasource, maps instructions between the twoDataSet Provides an in-memory representation of your data sourceDataReader Read-Only forward stream containing your data
  9. 9. Advantages Interoperability  Data is transported as XML  Can be read by anyone on any platform Scalability  Client Server model is gone  ADO promotes the use of disconnected datasets Productivity  Quicker  Less Bugs
  10. 10. Advantages Cont’d Performance  Disconnected datasets  Database Server is no longer a bottleneck  Performance boost  Concurrency  Database not locked out all the time
  11. 11. Using ADO.NET in Code1. Set up your objects2. Connect to DB using connection object3. Set up the data adapter4. Copy data from data adapter to Dataset
  12. 12. Connecting to a DB in CodeUSING ADO.NET WITH ACCESS DB
  13. 13. A Simple DB Application
  14. 14. Code Cont’d
  15. 15. Code Cont’d
  16. 16. Code Cont’d
  17. 17. Doing it In Code An access Database Table It will be represented in our DataSet as a Table The first table is given an index of 0 The first row in the table has an index value of 0 also The first column has a value of 0
  18. 18. Code Cont’d
  19. 19. The CodeSet up the objects
  20. 20. The CodeSet up the objects
  21. 21. The CodeSet up the objects
  22. 22. The CodeSet up the objects
  23. 23. The CodeSet up the objects
  24. 24. The CodeFill the DataSet using the DataAdapter
  25. 25. The Code – Displaying the DataSet Contents Point a textbox to a row and column of the dataset Table Point a DataGrid control at a DataSet ......................................................................................................... .
  26. 26. The Code: Counting theNumber of Rows
  27. 27.  Point a textbox to a row and column of the dataset Table Point a DataGrid control at a DataSet ......................................................................................................... .
  28. 28. Customising the GenericCode
  29. 29. Set Up the Objects
  30. 30. The Form Load Code
  31. 31. The UpdateTextBoxes SubProcedure
  32. 32. Navigation Code: PreviousRecord
  33. 33. Navigation Code: Next Record
  34. 34. Navigation Code: Find Record

×