logo       

Philosophical take on how to fetch a data structure from SQL Server 2000: msg#00020

org.user-groups.dotnet.padnug

Subject: Philosophical take on how to fetch a data structure from SQL Server 2000


What is your philosophical take on how to fetch a data structure?

What I have working is:
1) Create a DAL Service that uses the IDE GUI data controls SqlDataAdapter,
SqlConnection, and then have it generate a DataSet. Then I write this function
that returns just the structure of the DataTable.

Public Function GetAddressStructure() As DataTable
'Gets the Structure without data for the Address Table
Dim dt As New DataTable
Dim ds As New DataSet
ds = Me.DsAddresses1.Clone
dt = ds.Tables(0)
Return dt
End Function

2) Now the guys here want me to move code in Stored Procedures for database
access, however this aspect of grabbing the Data Structure, is somewhat in a
gray area in between is it not? Or is there a way using Stored Procedures to
just grab the Data Structure.

3) Reason for grabbing the Data Structure is to build a DataRow to build a
SqlParameter array to pass into the Stored Procedures.

Public Function ConvertClassToDataRow(ByVal pAddr As clsLocation) As DataRow
'converts the class into a dataRow
Dim dt As New DataTable
dt = myAddr.GetAddressStructure
Dim newRow As DataRow = dt.NewRow()
With pAddr
newRow("AddressLine1") = .Addr1
newRow("AddressLine2") = .Addr2
newRow("City") = .City
newRow("State") = .State
newRow("ZipCode") = .Zip
End With
Return newRow
End Function

4) Works really fine.

Anyone have any better coding practices in doing this? Thought about copying
the generated DataSet.xsd & it's code behind page into a separate solution,
then testing if I can do the same thing...then philosophically being able to
tweak the xsd manually later if the database changes...

What do you think?




=====
Elizabeth Gee
Information Architect
http://www.nwtd.com





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise