SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
Go Back  Xtreme Visual Basic Talk > > > > SqlDatabaseUtilities - a data layer helper for SQL server


Reply
 
Thread Tools Display Modes
  #1  
Old 10-28-2005, 06:23 AM
Merrion's Avatar
MerrionSqlDatabaseUtilities - a data layer helper for SQL server Merrion is offline
Ultimate Contributor

* Guru *
 
Join Date: Sep 2001
Location: Dublin, Ireland
Posts: 1,828
Default SqlDatabaseUtilities - a data layer helper for SQL server


Basically this project is a set of classes that make it possible to read and write your .NET classes (and collections of same) to SQL Server tables.

For example suppose you have a table such as:
Code:
CREATE TABLE Address
  (
   Id uniqueidentifier NOT NULL,
   [Line 1] varchar(255) NULL,
   [Line 2] varchar(255) NULL,
   [Line 3] varchar(255) NULL,
   [Post Code] varchar(10) NULL,
   [User Name] varchar(220) NULL,
   Timestamp datetime NOT NULL
   )
And you have an unique index on Id.

You can create a .NET class to mirror this table:-
Code:
<DatabaseTable("Address")> _ Public Class Address Private _Id As Guid Private _Line_1 As String = "" #Region "Id" <DatabaseField("Id", True)> _ Public Property Id() As Guid Get Return _Id End Get Set(ByVal value As Guid) _Id = value End Set End Property #End Region #Region "Line 1" <DatabaseField("Line 1")> _ Public Property Line1() As String Get Return _Line_1 End Get Set(ByVal Value As String) If Value <> _Line_1 Then _Line_1 = Value End If End Set End Property #End Region '--8<--------------------------------etc for other fields... End Class

Because this class has been marked with attributes (DatabaseTable() and DatabaseField() ) there is now sufficient information to read it and write it to the database table "Address".

For example to load the class with data from the table:-
Code:
Public Function GetHomeAddress(Byval Id As Guid) As Address Dim HomeAddress As New Address HomeAddress.Id = Id Dim SQLTableInterop As New SQLTableInterop(_connectionstring) SQLTableInterop.GetObjectDataFromTable(HomeAddress) Return HomeAddress End Function

and when you have changed the class you can save it back to the table thus:-
Code:
Dim SQLTableInterop As New SQLTableInterop(_connectionstring) SQLTableInterop.SetObjectDataToTable(HomeAddress)

This becomes more useful the more tables and classes your application involves...

Last edited by Shurik12; 07-26-2006 at 10:12 AM. Reason: Removed compiled dll from zip
Reply With Quote
  #2  
Old 03-30-2006, 09:20 AM
Merrion's Avatar
MerrionSqlDatabaseUtilities - a data layer helper for SQL server Merrion is offline
Ultimate Contributor

* Guru *
 
Join Date: Sep 2001
Location: Dublin, Ireland
Posts: 1,828
Default

New version (attached) now does an INSERT to the table if the key fields (as held in the object) are not already on the table when the SetObjectdataToTable method is called

Last edited by Shurik12; 07-26-2006 at 10:12 AM.
Reply With Quote
  #3  
Old 06-20-2006, 04:57 AM
Merrion's Avatar
MerrionSqlDatabaseUtilities - a data layer helper for SQL server Merrion is offline
Ultimate Contributor

* Guru *
 
Join Date: Sep 2001
Location: Dublin, Ireland
Posts: 1,828
Default

New version for visual studio 2005 - now allows nullable types and serialises them as dbNull if no value is set.
Attached Files
File Type: zip Data Access.zip (20.1 KB, 93 views)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
 
SqlDatabaseUtilities - a data layer helper for SQL server
SqlDatabaseUtilities - a data layer helper for SQL server
 
-->