01.
Imports
System.Web.Services
02.
Imports
System.Web.Services.Protocols
03.
Imports
System.ComponentModel
04.
Imports
System.Data
05.
Imports
System.Data.SqlClient
06.
07.
08.
10.
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
11.
<ToolboxItem(
False
)> _
12.
Public
Class
Service1
13.
Inherits
System.Web.Services.WebService
14.
15.
Dim
objConn
As
New
System.Data.SqlClient.SqlConnection
16.
Dim
objCmd
As
New
System.Data.SqlClient.SqlCommand
17.
Dim
dtAdapter
As
New
System.Data.SqlClient.SqlDataAdapter
18.
<WebMethod()> _
19.
Public
Function
HelloWorld()
As
DataSet
20.
Dim
ds
As
New
DataSet
21.
Dim
strConnString, strSQL
As
String
22.
strConnString =
"Server=localhost\SQL2008;UID=sa;PASSWORD=sqlserver2008;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
23.
strSQL =
"SELECT * FROM customer"
24.
objConn.ConnectionString = strConnString
25.
With
objCmd
26.
.Connection = objConn
27.
.CommandText = strSQL
28.
.CommandType = CommandType.Text
29.
End
With
30.
dtAdapter.SelectCommand = objCmd
31.
32.
dtAdapter.Fill(ds)
33.
34.
dtAdapter =
Nothing
35.
objConn.Close()
36.
objConn =
Nothing
37.
38.
Return
ds
39.
End
Function
40.
41.
End
Class