my.ASPItalia.com
ASP.NET
|
HTML5
|
LINQ e Entity Framework
|
Silverlight
|
Windows Phone
|
.NET Framework
|
Libro WP7
|
Libro HTML5
|
Corso on-site HTML5
Iscriviti
Login
Newsletter
Home
Articoli
Script
Notizie
FORUM
Blogs
Lab
Media
Tutorials
Corsi
Libri
Tags
Tutti i forum
Ricerca
FAQ
Fai una domanda
LETTURA DATI IN DB SQLSERVER
in
.NET Framework
>
Windows Communication e Workflow
Ultimo messaggio
DianaWeb
il 15 settembre 2009 alle 08:55
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
Rispondi
Quoting
Ricciolo
il 21 settembre 2009 alle 19:55
5.514 messaggi
dal 26 febbraio 2001
Contributi
blogs.aspitalia.com
|
Blog
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
Rispondi
Quoting
Salto rapido
Ultimi messaggi
Tutti i forum
Ricerca
Utenti online
ASP.NET
ASP.NET 2.0
ASP.NET 3.5
ASP.NET 4.0
.NET Framework
Silverlight
Windows Phone
Windows Presentation Foundation e WinForms
Windows Communication e Workflow
ASP - avanzato
ASP - base
SQL Server e MySQL
Libri
Hosting
Altri linguaggi e tecnologie
Windows Server, IIS & Security
E-commerce
OT
Commenti: blogs e notizie
Eventi
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
Speciale web mobile: costruire applicazioni con ASP.NET, jQuery Mobile e PhoneGap
Speciale Silverlight 5: tutte le novità
Rilasciato il bollettino MS11-100 per risolvere i problemi di attacchi DoS di ASP.NET
I più letti di oggi
Windows Phone 7.5 Developer Day: marketplace e strumenti per monetizzare le app
Le funzionalità di drag and drop di Silverlight 4.0
Mobile Web con ASP.NET: Web Forms e MVC nel palmo di una mano (Real Code Day 6)
.NET Campus: Creare applicazioni veloci e user-friendly con jQuery, Microsoft AJAX Library e ASP.NET
Introduzione a LINQ, LINQ to XML, Object e DataSet
Visualizzare un template per browser mobile tramite un custom control ASP.NET
Speciale web mobile: costruire applicazioni con ASP.NET, jQuery Mobile e PhoneGap
Media
Windows Phone 7.5 Developer Day: marketplace e strumenti per monetizzare le app
Windows Phone 7.5 Developer Day: costruire app con Visual Studio 2010 e Windows Phone Runtime
Tutti i media
In evidenza
Speciale web mobile: costruire applicazioni con ASP.NET, jQuery Mobile e PhoneGap
Speciale Silverlight 5: tutte le novità
Sviluppare applicazioni per Windows Phone: scopri come fare con il nostro nuovissimo libro!
Sviluppa le applicazioni del futuro oggi: impara con il nostro libro HTML5 Espresso!
Community Days 2012 - Milano
Visualizzare un template per browser mobile tramite un custom control ASP.NET
Windows 8 su ARM: avrà il desktop, Office e il connected standby
Rilasciato Entity Framework 4.3
MISC
I nostri autori
Collabora con noi!
Media Kit - Pubblicità sul nostro network