คือ ผมได้ เขียนโค้ด ของทางฝั่ง web service แล้ว ทีนี้ ผมจะเขียนฝั่ง client แสดงโชว์ เป็น listbox ภาษา vb ยังไงดีครับ
นี้โค้ดครับ
Code (VB.NET)
Imports System.Web
Imports System.Collections
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
<WebService([Namespace]:="MyWebSerice", Description:="Product")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class full
Inherits System.Web.Services.WebService
<WebMethod(Description:="Returns all Products")> _
Public Function GetProduct() As System.Data.DataSet
Dim ds As New DataSet()
Dim ds2 As New DataSet()
Dim conn As New SqlConnection()
conn = New SqlConnection("Data Source=WHATZ-PC\SQLEXPRESS;Initial Catalog=test;User ID=admin;Password=1234")
conn.Open()
Dim cmd As New SqlCommand("SELECT * FROM Product", conn)
cmd.CommandType = CommandType.Text
Dim adapter As New SqlDataAdapter()
Try
adapter.SelectCommand = cmd
Catch
Return Nothing
End Try
adapter.Fill(ds2, "Product")
Return ds2
End Function
End Class
Public Class Form1
Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGet.Click
Dim GetData As GetFull.fullSoapClient
Dim ds2 As DataSet = New DataSet
ListBox1.DataSource = ds2.Tables("Name")
End Sub
End Class