PDA

View Full Version : Una mano per un Web Service, mi basta un piccolo aito.......


race2
13-04-2002, 14:31
Dato il seguente Web Service:


Lato Server:
-----------------------------------------------------------------------------------
Imports System.Web.Services
Imports System.Data.SqlClient

Public Class Service1
Inherits System.Web.Services.WebService



<WebMethod()> Public Function GetAll() As DataSet

Dim conn As New SqlConnection("Data Source=localhost;Initial Catalog=pubs; Integrated Security=SSPI;")
Dim sda As New SqlDataAdapter("SELECT * FROM jobs", conn)
Dim ds As New DataSet()
sda.Fill(ds, Table)
Return ds

End Function

End Class
-----------------------------------------------------------------------------------



Lato Client:
-----------------------------------------------------------------------------------

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim s As localhost.Service1 = New localhost.Service1()
Dim ds As DataSet = s.GetAll()
dtg.DataSource = ds.Tables("jobs")

End Sub

End Class
-----------------------------------------------------------------------------------

dtg = DataGrid

ho creato il riferimento web chiamato "localhost"

Funziona benissimo, mi visualizza in un DataGrid tutto il contenuto della tabella "jobs" residente nel server.

Ma se osservate il tutto e' un servizio molto statico, se io volessi ad esempio inviare dal Lato Client il nome della tabella che deve essere visualizzata, oppure se aggiungo al Web Service una clausura "WHERE nome = ' & nome &' " e volessi inviare il nome da ricercare ???

questo e' il mio problema per completare il Web Service.