45 messaggi dal 16 aprile 2008
Salve avrei un dubbio. Per il recupero di dati da db ho elaborato funzioni che restituiscono dataset ovvero:

Public Function GetIdPallet(ByVal CodiceDitta As Decimal, ByVal Anno As Decimal, ByVal Codice As Decimal) As DataSet Implements IWcfService.GetIdPallet
Dim ModuleBase As New ModuleBase
Dim strsql As String
strsql = " SELECT dbo.DO30_DOCCORPO.DO30_CODART_MG66, dbo.DO30_DOCCORPO.DO30_DESCART, dbo.BSL36_PICKINGMOV.BSL36_QUANTITA"
strsql = strsql & " FROM dbo.BSL35_PICKINGANAG INNER JOIN"
strsql = strsql & " dbo.BSL36_PICKINGMOV ON dbo.BSL35_PICKINGANAG.BSL35_DITTA_CG18 = dbo.BSL36_PICKINGMOV.BSL36_DITTA_CG18 AND "
strsql = strsql & " dbo.BSL35_PICKINGANAG.BSL35_ANNO = dbo.BSL36_PICKINGMOV.BSL36_ANNO_BSL35 AND "
strsql = strsql & " dbo.BSL35_PICKINGANAG.BSL35_IDPICKING = dbo.BSL36_PICKINGMOV.BSL36_IDPICKING_BSL35 INNER JOIN"
strsql = strsql & " dbo.DO30_DOCCORPO ON dbo.BSL36_PICKINGMOV.BSL36_DITTA_CG18 = dbo.DO30_DOCCORPO.DO30_DITTA_CG18 AND "
strsql = strsql & " dbo.BSL36_PICKINGMOV.BSL36_NUMREG_DO30 = dbo.DO30_DOCCORPO.DO30_NUMREG_CO99 AND "
strsql = strsql & " dbo.BSL36_PICKINGMOV.BSL36_PROGRIGA_DO30 = dbo.DO30_DOCCORPO.DO30_PROGRIGA INNER JOIN"
strsql = strsql & " dbo.DO11_DOCTESTATA ON dbo.DO30_DOCCORPO.DO30_DITTA_CG18 = dbo.DO11_DOCTESTATA.DO11_DITTA_CG18 AND "
strsql = strsql & " dbo.DO30_DOCCORPO.DO30_NUMREG_CO99 = dbo.DO11_DOCTESTATA.DO11_NUMREG_CO99"
strsql = strsql & " WHERE BSL35_DITTA_CG18 = " & CodiceDitta
strsql = strsql & " and BSL35_ANNO = " & Anno & " and BSL35_IDPICKING=" & Codice


Return ModuleBase.GetDataSet(strsql)
End Function


Di seguito una funzione che in base alla query popola il dataset


ublic Class ModuleBase
Public Function GetDataSet(ByVal strSQL As String) As DataSet

Dim ConnectionString As String

ConnectionString = "Server=192.168.10.203;Database=Eurofrigor;uid= sa;pwd= sa"
'1. Create a connection
Dim myConnection As New SqlConnection(ConnectionString)

'2. Create the command object, passing in the SQL string
Dim myCommand As New SqlCommand(strSQL, myConnection)

myConnection.Open()

'3. Create the DataAdapter
Dim myDataAdapter As New SqlDataAdapter()
myDataAdapter.SelectCommand = myCommand


'4. Populate the DataSet and close the connection
Dim myDataSet As New DataSet()
myDataAdapter.Fill(myDataSet)
myConnection.Close()

'Return the DataSet
Return myDataSet
End Function



Il mio dubbio è il seguente ma se devo leggere un solo record o scrivere record nel db e lo volessi fare tramite funzioni inserite in un wcf quale sarebbe il miglio metodo.

Grazie in anticipo
eh, il metodo migliore sarebbe non usare il DataSet, ma usare direttamente SqlDataReder, SqlConnection ecc. Se vuoi evolvere un po' l'architettura, dai un occhio qua http://www.aspitalia.com/articoli/architettura/layered-architecture.aspx e qua http://www.aspitalia.com/articoli/architettura/object-model.aspx

Ciao

Il mio blog
Homepage

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.
In primo piano

I più letti di oggi

Media
In evidenza
MISC