Hi there,
Having a problem with linking two autocompletes, they are ajax controls.
They are designed to look up a surname first and then a forename, depending on the surname.
The first looks like this and works fine (surname):
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports Oracle.DataAccess.Client<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 autocomp
Inherits System.Web.Services.WebService<WebMethod()> _
Public Function SearchCustomers(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim myOraCon As OracleConnection
myOraCon = New OracleConnection
myOraCon.ConnectionString = ConfigurationManager.ConnectionStrings("OracleConnectionString").ConnectionString
Dim cmd As New OracleCommand
cmd.Connection = myOraCon
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT DISTINCT SURNAME FROM table_name WHERE SURNAME LIKE :SearchText || '%'"
cmd.Parameters.Add(":SearchText", OracleDbType.NVarchar2).Value = prefixText
myOraCon.Open()
Dim customers As List(Of String) = New List(Of String)
Dim sdr As OracleDataReader = cmd.ExecuteReader
While sdr.Read
customers.Add(sdr("SURNAME").ToString)
End While
myOraCon.Close()
myOraCon.Dispose()
Return customers
End Function
End ClassSo as I said the above works and only displays the surname in one text, the users hits fetch and a new textbox is displayed for the forenames to appear. The page is also refreshed and the surname sent as part of a URL query string, i.e ?surname=jones etc
The avaliable forenames should be picked up from the code below using the text from the URL query string.
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports Oracle.DataAccess.Client<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 autocomp2
Inherits System.Web.Services.WebService<WebMethod()> _
Public Function SearchCustomers2(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim surname As String
surname = HttpContext.Current.Request.UrlReferrer.Query
Dim equals_index = surname.IndexOf("=")
Dim length_of_surname As Integer = (surname.Length - 1) - equals_index
surname = surname.Substring(equals_index + 1, length_of_surname)
Dim myOraCon As OracleConnection
myOraCon = New OracleConnection
myOraCon.ConnectionString = ConfigurationManager.ConnectionStrings("OracleConnectionString").ConnectionString
Dim cmd As New OracleCommand
cmd.Connection = myOraCon
cmd.CommandType = CommandType.Text
'cmd.CommandText = "SELECT FORENAME FROM table_name WHERE SURNAME like 'Cook%' order by 1"
cmd.CommandText = "SELECT FORENAME FROM table_name WHERE FORENAME LIKE :SearchText || '%' AND SURNAME = :surname || '%'"
cmd.Parameters.Add(":SearchText", OracleDbType.NVarchar2).Value = prefixText
cmd.Parameters.Add(":surname", OracleDbType.NVarchar2).Value = surname
myOraCon.Open()
Dim customers As List(Of String) = New List(Of String)
Dim sdr As OracleDataReader = cmd.ExecuteReader
While sdr.Read
customers.Add(sdr("FORENAME").ToString)
End While
myOraCon.Close()
myOraCon.Dispose()
Return customers
End Function
End Class
I have inspected my code and the sql appears correct, the surname appears there when I look at it. Just not sure why no results are being displayed in the forename box.
Any one got any ideas? . . .