Quindi mi stai dicendo che se si lavora solo escusivamente su un db sql è meglio utilizzare le stored procedure e richiamarle sull'applicativo attraverso le creazione di classi che a loro interno vi sono delle funzioni che richiamano le stored specifica come in questo esempio:
Imports System.Data.SqlClient
Public Class GestoreNazioni
Public Function CaricaRec(ByVal ObjNazione As PropertyNazioni) As PropertyNazioni
Dim oNazione As PropertyNazioni = New PropertyNazioni
Try
SqlCmd.CommandText = "GetNazione_new"
SqlCmd.Parameters.Add("@Nazione", SqlDbType.VarChar).Value = ObjNazione.Nazione
SqlCmd.Connection = Db
SqlCmd.CommandType = CommandType.StoredProcedure
SqlDr = SqlCmd.ExecuteReader
If SqlDr.Read() Then
oNazione.Nazione = SqlDr.GetSqlString(0).Value()
oNazione.CodiceNazIstat = SqlDr.GetSqlInt32(1).Value
End If
Return oNazione
Catch ex As Exception
Throw ex
Finally
SqlDr.Close()
SqlCmd.Parameters.Clear()
SqlCmd.Dispose()
End Try
End Function
End Class
Public Class PropertyNazioni
Private codnazIstat As Int32
Private Naz, Codnaz As String
Public Property CodiceNazIstat() As Int32
Get
Return codnazIstat
End Get
Set(ByVal value As Int32)
codnazIstat = value
End Set
End Property
Public Property Nazione() As String
Get
Return Naz
End Get
Set(ByVal value As String)
Naz = value
End Set
End Property
Public Property CodNazione() As String
Get
Return Codnaz
End Get
Set(ByVal value As String)
Codnaz = value
End Set
End Property
End Class
Public Class NazioniCollection
Inherits CollectionBase
' Aggiunge l'oggetto alla collection
Public Sub Add(ByVal item As PropertyNazioni)
List.Add(item)
End Sub
' Ritorna l'n-esimo elemento
Public ReadOnly Property Item(ByVal index As Int32) As PropertyNazioni
Get
Return CType(List(index), PropertyNazioni)
End Get
End Property
End Class
Cirillo Fabio
www.wondernet.biz
fabio@wondernet.biz
http://blogs.dotnethell.it/fabiocirillo/
http://wnetsoftware.blogspot.com