01.
Imports
System.Web
02.
Imports
System.Web.Services
03.
Imports
System.Web.Services.Protocols
04.
Imports
System.Linq
05.
Imports
System.Data
06.
Imports
System.Data.SqlClient
07.
08.
09.
<System.Web.Script.Services.ScriptService()> _
11.
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
12.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
13.
Public
Class
AutoCompleteWebServices
14.
Inherits
System.Web.Services.WebService
15.
16.
<WebMethod()> _
17.
Public
Function
GetDistrictList(
ByVal
prefixText
As
String
,
ByVal
count
As
Integer
,
ByVal
contextKey
As
String
)
As
String
()
18.
19.
Dim
returnList
As
New
List(Of
String
)
20.
21.
Try
22.
23.
Dim
_sId
As
String
=
String
.Empty
24.
Dim
CallId
As
String
=
String
.Empty
25.
Dim
CallerPhoneCode
As
String
=
String
.Empty
26.
27.
Dim
params
As
String
() = contextKey.Split(
"|"
)
28.
_sId = params(0)
29.
CallId = params(1)
30.
CallerPhoneCode = params(2)
31.
32.
33.
Dim
objConn
As
New
SqlConnection
34.
Dim
dtAdapter
As
SqlDataAdapter
35.
Dim
dt
As
New
DataTable
36.
Dim
i
As
Integer
= 0
37.
38.
39.
Dim
strConnString
As
String
40.
strConnString = ConfigurationManager.ConnectionStrings(
"SQL2008SamplesDBConnectionString"
).ConnectionString
41.
objConn =
New
SqlConnection(strConnString)
42.
objConn.Open()
43.
44.
Dim
strSQL
As
String
45.
strSQL =
"SELECT * FROM Cities WHERE Description like '"
& prefixText &
"%'"
46.
47.
dtAdapter =
New
SqlDataAdapter(strSQL, objConn)
48.
dtAdapter.Fill(dt)
49.
50.
dtAdapter =
Nothing
51.
52.
objConn.Close()
53.
objConn =
Nothing
54.
55.
For
i = 0
To
dt.Rows.Count - 1
56.
returnList.Add(dt.Rows(i)(
"Description"
).ToString())
57.
Next
58.
59.
dt.Clear()
60.
61.
Catch
ex
As
Exception
62.
63.
End
Try
64.
65.
Return
returnList.ToArray()
66.
67.
End
Function
68.
69.
End
Class