|
-
Sep 21st, 2005, 06:16 PM
#1
Thread Starter
Junior Member
Data Tier help
Hello all i am in need of some help with a datatier layout.
I understand the gui, bussinessRules, but i am really not making any progress on the data tier. i have been tring to get a grip on the this one for over a week. I completely understand the concept, i am confused when it comes to what implemetion i should use.. Some say a dataset,, some say a datareader,,
Can someone please send me a url (and i have read alot of googles ones already) or of a way to implement this and different options that i can use..
Here is the 'Duwamish7 example from the sdks,,,, i am just lost when i think of how i should do this without the dataset.. What other kind of store can i use and how can i implement this..
sos here
Please here,
Erik,.,
Option Strict On
Option Explicit On
Imports System
Imports System.Data
Imports System.Runtime.Serialization
Namespace Duwamish7.Common.data
'----------------------------------------------------------------
' Namespace: Duwamish7.Common.Data
' Class: BookData
'
' Description:
' A custom serializable dataset containing book information.
'----------------------------------------------------------------
<System.ComponentModel.DesignerCategory("Code"), SerializableAttribute()> Public Class BookData
Inherits DataSet
'
' Books table constants
'
Public Const BOOKS_TABLE As String = "Books"
Public Const PKID_FIELD As String = "PKId"
Public Const TYPE_ID_FIELD As String = "TypeId"
Public Const PUBLISHER_ID_FIELD As String = "PublisherId"
Public Const PUBLICATION_YEAR_FIELD As String = "PublicationYear"
Public Const ISBN_FIELD As String = "ISBN"
Public Const IMAGE_FILE_SPEC_FIELD As String = "ImageFileSpec"
Public Const TITLE_FIELD As String = "Title"
Public Const DESCRIPTION_FIELD As String = "Description"
Public Const UNIT_PRICE_FIELD As String = "UnitPrice"
Public Const UNIT_COST_FIELD As String = "UnitCost"
Public Const ITEM_TYPE_FIELD As String = "ItemType"
Public Const PUBLISHER_NAME_FIELD As String = "PublisherName"
Public Const AUTHORS_FIELD As String = "Authors"
'----------------------------------------------------------------
' Search Type Enum
' Each item is currently ordered and valued to match the layout in
' advsrch.cls changing these values will cause problems with
' functionality in the advsrch class.
'----------------------------------------------------------------
<SerializableAttribute()> Public Enum SearchTypeEnum
Title = 0
ISBN = 1
Author = 2
Subject = 3
ID = 4
IdList = 5
End Enum
'----------------------------------------------------------------
' Sub New:
' Constructor to support serialization.
'----------------------------------------------------------------
Private Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New(info, context)
End Sub
'----------------------------------------------------------------
' Sub New:
' Initialize a BookData instance by building the table schema.
'----------------------------------------------------------------
Public Sub New()
MyBase.New()
'
' Create the tables in the dataset
'
BuildDataTables()
End Sub
'----------------------------------------------------------------
' Sub BuildDataTables:
' Creates the following datatables: Books
'----------------------------------------------------------------
Private Sub BuildDataTables()
'
' Create the Books table
'
Dim table As DataTable = New DataTable(BOOKS_TABLE)
With table.Columns
.Add(PKID_FIELD, GetType(System.Int32))
.Add(TYPE_ID_FIELD, GetType(System.Int32))
.Add(PUBLISHER_ID_FIELD, GetType(System.Int32))
.Add(PUBLICATION_YEAR_FIELD, GetType(System.Int16))
.Add(ISBN_FIELD, GetType(System.String))
.Add(IMAGE_FILE_SPEC_FIELD, GetType(System.String))
.Add(TITLE_FIELD, GetType(System.String))
.Add(DESCRIPTION_FIELD, GetType(System.String))
.Add(UNIT_PRICE_FIELD, GetType(System.Decimal))
.Add(UNIT_COST_FIELD, GetType(System.Decimal))
.Add(ITEM_TYPE_FIELD, GetType(System.String))
.Add(PUBLISHER_NAME_FIELD, GetType(System.String))
'
' [Authors] is an optional column that will get added dynamically to the table schema
' when the stored proc. GetBookById is used to fill the 'Books' table
'
End With
Me.Tables.Add(table)
End Sub
End Class 'BookData
End Namespace 'Duwamish7.Common.Data
-
Sep 22nd, 2005, 06:26 AM
#2
Addicted Member
Re: Data Tier help
i suggest the dataset as the general method of communication between layers and in particular a strongly-typed one. Perhaps a datatable when the contents being returned isn't to complex or has no meaningful relationships i.e. GUI widgets like combo boxes etc.
there are tools out there that will go a fair way in creating a datalayer for you (Object/Relational mappers) - http://www.olero.com/OrmWeb/ - have a tinker with that
PS**
also you might want to check out the Microsoft Data Access Application Block - http://msdn.microsoft.com/library/de.../html/daab.asp
Last edited by powdir; Sep 22nd, 2005 at 06:31 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|