Workshop

for RuBoard

This workshop will help reinforce the concepts covered in today's lesson.

Quiz

1:

What is the difference between a generic and a specific .NET Data Provider?

A1:

A generic provider can be used with more than one data store, whereas a specific provider is implemented to communicate with a single data store. The OleDb and ODBC providers from Microsoft are examples of generic providers, and the SqlClient and future Oracle providers are examples of specific providers. Typically, specific providers will outperform generic providers at the cost of flexibility.

2:

Which components of a .NET Data Provider are not provided as templates by ADO.NET?

A2:

As shown in Figure 8.1, the command builder, error, and exception objects are all implemented independently by each provider because there are no classes or interfaces to inherit from in the System.Data or System.Data.Common namespaces.

3:

How can a provider allow for secured access to the underlying data store?

A3:

Providers have the option of implementing custom permission classes inherited from DbDataPermission and DbDataPermissionAttribute . These classes allow both imperative and declarative security checks to be placed in code so that the common language runtime can verify that a particular assembly has been granted the permission. Permissions can be created at virtually any granularity.

4:

What is the visibility of data returned through a data reader?

A4:

That depends on the provider and data store in question. Typically, data returned from a data reader is static data and so changes made by other users will not be visible. However, because a data reader remains connected to a data store while it is being traversed, providers can reflect changes to rows and new rows if needed.

Exercise

Q1:

Write a custom error handling routine similar to that shown in Listing 8.2 to report errors when an OleDbException is raised.

A1:

One possible solution to the exercise is as follows :

 Public Sub LogOleDbErrors(ByVal myException As OleDbException)   Dim oleDbE As OleDbError   Dim strMsg As String   ' Write the header and stack dump   Trace.WriteLine("OleDbException occurred at " & _    Now.ToLongTimeString & " in " & myException.TargetSite.Name)   Trace.WriteLine(myException.StackTrace)   ' Walk through all of the errors   For Each E In myException.Errors     strMsg = "Source: " & oleDbE.Source & ControlChars.Cr & _         "NativeError: " & oleDbE.NativeError.ToString() & ControlChars.Cr & _         "State: " & oleDbE.SQLState.ToString() & ControlChars.Cr & _         "Message: " & oleDbE.Message     Trace.WriteLine(strMsg)   Next   Trace.WriteLine("End of OleDbException") End Sub 
for RuBoard


Sams Teach Yourself Ado. Net in 21 Days
Sams Teach Yourself ADO.NET in 21 Days
ISBN: 0672323869
EAN: 2147483647
Year: 2002
Pages: 158
Authors: Dan Fox

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net