I'm new to Ajax, using VB2008 in ASP.net 3.5 VS2008 against SQL Server 2005. I'm trying to get a textbox to populate a gridview with a list of potential returns which gets shorter with each user's keystroke. My code works if I hit enter or add a button to click. However, if I understand what I'm reading, the addition of the Ajax autocompletextender to my textbox should accomplish keystroke-by-keystroke data-listing and the reduction of the returned data.
My problem is that in the code that follows, when the line of code
suggestions.Add(dbDs.Tables(0).Rows(i - 1).Item(0).ToString)
finishes and before the
Next
i
executes, when the count is 20 (or whatever), I return to the textbox. I don't see my error and I don't crash, but I don't get the results I expect. I'd appreciate any help - thanks in advance. My code follows:
Imports
System.Data.SqlClient
Imports
System.Data
Imports
System.Web
Imports
System.Web.Services
Imports
System.Web.Services.ProtocolsImports System.Collections.Generic<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<
Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class AutoCompleteInherits System.Web.Services.WebService
<WebMethod()> _
Public Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()
'Create a Connection object
Dim connObject As String = "Data Source=SCMD-XP-92;Initial Catalog=Northwind;Integrated Security=True providerName=System.Data.SqlClient"
'Create a Select command to execute
Dim dbGet As String = "SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle] FROM [Customers] WHERE ([CustomerID] LIKE @CustomerID + '%')"Dim suggestions As New List(Of String)
'Create a DataSet to populateDim dbDs As New DataSetFor i As Integer = 1 To count
suggestions.Add(dbDs.Tables(0).Rows(i - 1).Item(0).ToString)
Next i
'Create a DataAdapter to connectDim daSql As New SqlDataAdapter(dbGet, connObject)
daSql.Fill(dbDs)
Return suggestions.ToArray()
End Function
End
Class