Shopping Cart(0)
|
Lightbox(0)
|
Login
Stock Photos
ASP.Net Primer
Web Hosting
Create a DAL for an ObjectDataSource
ASP.Net Primer
Web Application Vs Web Site
Web Site Techniques
DataSource Overview
Create a DAL for an ODS
Advanced ObjectDataSource
Adventures in .net Paging
Add Paging to a DataList
Repeater PagedDataSource
Advanced ObjectDataSource
SQL Server Primer
Apply
Common Functions
Cast
Convert
Date Functions
Null Functions
Lower & Upper
Except
Intersect
Pivot
RowNumber & Rank
Software Primer
XML Overview
Name Your Site
Syndicate With RSS
Web Design - Get a Spine!
Security: What Hackers Do
Intro To PHP
CGI: What & How?
Web Marketing
Start a Traffic Virus
Create A DataAcessLayer for an ObjectDataSource
ASP.Net tutorial ©2012
Next Page
An ASP.Net ObjectDataSource can be easily wired to a Data Access Layer (DAL) in Visual Studio. Best practices dictates that the User Interface, Business Logic, and Data Access functionality be separated into different tiers.
While a DAL does not provide a business layer, it does separate data access functionality from the user interface.
C# Sample Code
Note: These dialogs are from a Web Application. The dialogs may differ in Web Projects or WinForms
Download
and install the Northwind database.
1.
In Solution Explorer, right click on the App_Code folder and select "Add New Item". Select "Add Dataset".
2.
From Server Explorer, drag and drop a table to the Dataset Designer.
3.
The Dataset Designer will now display the data table. A web.config connection string was automatically created. There should be a single web connection string. If a connection string is already configured, right-click on the data table TableAdapter and in the context menu select Properties. Update Connection to point to the previously setup connection. You should also remove the newly added connection string from your web.config to keep it nice and tidy.
4.
Right-click on the table adapter and select "Add Query".
5.
Select a Command Type.
6.
Select one of the Query Types. In this example, "Select which returns rows" is selected.
7.
Enter a SQL Statement.
8.
Choose a Method to Generate and assign a Method Name.
9.
You should receive a message that table adapter was configured correctly. Select Finish.
Next Page
Powered by
www.ezjooz.com