Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have an n-tiered application which uses a (Data Access Layer) DAL to retrieve DataSets from the Database using "SELECT * FROM tblItemMaster" statements from individual tables as oppossed to using inner joins against multiple tables. I now want to be able to add relationships between these returned DataSets but realize that this is impossible as each table must be a DataTable inside a single DataSet.

 

My question (at last) is how do you call multiple select calls from a middle tier layer and then combine them into one dataset as tables, as oppossed to retrieveing multiple datasets.

Posted

Thanks Robby. Here's a simplified example of my DAL function, as you can see it returns a DataSet, with a table inside it called item.

 

Public Function Get_All() As DataSet

 

selectSQL = "SELECT * FROM tblItemMaster"

 

Dim mySelectCommand As OleDbCommand = New OleDbCommand(selectSQL, oConnection)

Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter(mySelectCommand)

 

Try

myOleDbDataAdapter.Fill(dsReturn, "Item")

myOleDbDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

myOleDbDataAdapter.FillSchema(dsReturn, SchemaType.Source, "Item")

Get_All = dsReturn

Catch exc As Exception

Throw exc

Finally

mySelectCommand.Dispose()

myOleDbDataAdapter.Dispose()

oConnection.Dispose()

End Try

 

End Function

 

 

My other DAL calls also return a Dataset named dsReturn with their own relevant table names, but I am not sure how to call these correctly from Business layer in order to combine them into one dataset.

 

Sorry if this reads a bit confusing....

  • Moderators
Posted

I prefer to not have the Select statement in my DAL as to keep it generic enough so it can be used by other applications. I setup sql statements as properties or arguments for the method so they are not known by the DAL.

Also, you can inherit the DAL from the business layer with MustInherit so that it is not instansiated.

Visit...Bassic Software
  • Moderators
Posted

It's not that much of a restructure, create a couple of private members to hold the SQL statement strings and have your methods execute them.

 

 

As for the relationships just move them to the business layer.

Visit...Bassic Software
Posted

Won't I still end up with multiple DataSets instead of DataTables as the DataAdapter would still be in the DAL.

 

PS. Sorry if I'm not getting the concept correctly

Posted

This is what I have:

 

Bus Level

 

Dim objCategory As New elantis_DAL.DALCategoryMaster()

Dim objItem As New elantis_DAL.DALItemMaster()

Dim objProductType As New elantis_DAL.DALProductType()

Dim objUnitOfMeasure As New elantis_DAL.DALUnitOfMeasure()

 

Try

Dim dsCategory As New DataSet()

Dim dsItem As New DataSet()

Dim dsProductType As New DataSet()

Dim dsUnitOfMeasure As New DataSet()

 

dsCategory = objCategory.Get_All()

dsItem = objItem.Get_All()

dsProductType = objProductType.Get_All() dsUnitOfMeasure = objUnitOfMeasure.Get_All()

 

 

I am ending up with 4 datasets instead of 1 dataset and 4 datatables.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...