vineri, 28 iunie 2013

Access Data Source C Sharp Solutions

Having employed the Access Data Source for a while has led me to the conclusion for most all my data connectivity needs the ADS can fill the bill for Microsoft Access Databases. Normal use and query building should be performed as usual in the visual designer. The obscured feature such as using a combination of events and the functions exposed allows a plethora of data solution possibilities. Did you know that a data reader is available to event? Not only is a data reader available but many of the functions we are comfortable with in the object linking database (OLEDB) are also available within the selected event. All data access and desired results are available through exposed events that use the SqlDataSourceStatusEventArgs.

To illustrate you could bind the executio of a query to any control. Before invoking the execution (via a control) place code inside the OnSelecting event for the data source to gain full access of the associated commands (e.Command.Connection.Open opens a connection to the data control). The e.Command.Parameters[0].Value exposed values to all parameters. Simply change the value between the brackets to to the respective parameter index and affect the value of the associated parameter. Session variables, cookie values and temporary storage can be used with the Convert function to get the raw information to the appropriate format for the parameter. The e.Command.CommandText property may be changed to establish a new query otherwise the existion query will be used. Now we are prepared to invoke the datareader. The main difference in this scenario is we use the System.Data.Common.DbDataReader object as opposed to System.Data.OleDb.OleDbDataReader object.

The reader usees identical read features and data retrieval features s of the OLEDB scenarios. We simple place the reader to the first record and process the fields. In typical fashion we could employ the While condition is true looping feature to process all the records retrieved by the data reader. When our pricessing is complete simply close the data reader followed by closing the connection.

Using the access data source in this manner allows us to leverage data access functionality and minimize the number of objects we need yielding tight fast execution code.



access point vs router

Niciun comentariu:

Trimiteți un comentariu