Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
Dim objConn As New System.Data.SqlClient.SqlConnection
Dim objCmd As New System.Data.SqlClient.SqlCommand
Dim dtAdapter As New System.Data.SqlClient.SqlDataAdapter
<WebMethod()> _
Public Function HelloWorld() As DataSet
Dim ds As New DataSet
Dim strConnString, strSQL As String
strConnString = "Server=localhost\SQL2008;UID=sa;PASSWORD=sqlserver2008;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
strSQL = "SELECT * FROM customer"
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
Return ds '*** Return DataSet ***'
End Function
End Class
Public Function getProvinces() As Province()
pcoc = New WindowsFormsApplication1.PCOCServiceReference.Service1SoapClient()
Dim myDataset As DataSet = pcoc.ProvinceSOA()
Dim provList As Province() = Nothing
If myDataset IsNot Nothing AndAlso myDataset.Tables.Count > 0 Then
Dim myTable As DataTable = myDataset.Tables(0)
provList = New Province(myDataset.Tables(0).Rows.Count - 1) {}
Dim i As Integer = 0
For Each myRow As DataRow In myTable.Rows
provList(i) = New Province()
provList(i).Id = myRow(myTable.Columns(0)).ToString()
provList(i).Name = myRow(myTable.Columns(1)).ToString()
i += 1
Next
End If
Return provList
End Function