Hi,

I need the autocomplete component in a VB.NET 2.0 project.  I kept the
.aspx page intact, and "translated" the CS file as good as I could, but
it doesn't seem to work (ie, the textboxes don't show a dropdown - the
same example in c# works perfectly).

I'll give the file that I made.  If we can fix it i'm sure other people
could use this too.  (I assume the examples aren't available in VB.NET
allready).




Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web

<AjaxPro.AjaxNamespace("AutoComplete")> _
    Partial Public Class AutoCompleteWebForm
    Inherits System.Web.UI.Page
    <AjaxPro.AjaxMethod()> _
     Public Function SimpleSearch(ByVal strsearch As String) As
DataTable
        Return Search(strsearch, 10)
    End Function

    <AjaxPro.AjaxMethod()> _
    Public Function Search(ByVal strsearch As String, ByVal count As
Integer) As DataTable
        Dim ds As DataSet = New DataSet()

        Dim conn As SqlConnection = New
SqlConnection("MYSQLCONNECTIONSTRING")

        Dim cmd As SqlCommand = New SqlCommand("SELECT DISTINCT TOP " +
count + " Postcode As CustomerID, Gemeente As CustomerName FROM
divpostcodes WHERE Gemeente LIKE @Name ORDER BY Gemeente", conn)
        cmd.Parameters.AddWithValue("@Name", strsearch + "%")
        Try
            conn.Open()

            Try
                Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
                da.Fill(ds)
            Finally
                conn.Close()
            End Try
        Catch ex As Exception
            Throw ex
        End Try
        If ds.Tables.Count = 1 Then
            Return ds.Tables(0)
        Else
            Return Nothing
        End If
    End Function


    <AjaxPro.AjaxMethod()> _
    Public Function SearchAdvanced(ByVal orderNumber As String, ByVal
customerID As Integer, ByVal count As Integer) As DataTable
        Dim ds As DataSet = New DataSet()

        Dim conn As SqlConnection = New
SqlConnection("MYSQLCONNECTIONSTRING")

        Dim cmd As SqlCommand = New SqlCommand("SELECT TOP " + count +
" Totaalnr As ID, Straat As OrderNumber FROM Straten WHERE Postnr =
@Postnr AND Straat LIKE @Straat ORDER BY Straat", conn)
        cmd.Parameters.AddWithValue("@Postnr", customerID)
        cmd.Parameters.AddWithValue("@Straat", orderNumber + "%")

        Try
            conn.Open()

            Try
                Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
                da.Fill(ds)
            Finally
                conn.Close()
            End Try
        Catch ex As Exception
            Throw ex
        End Try
        If ds.Tables.Count = 1 Then
            Return ds.Tables(0)
        Else
            Return Nothing
        End If
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
EventArgs)
        ' Register Ajax.NET methods from this class

AjaxPro.Utility.RegisterTypeForAjax(GetType(AutoCompleteWebForm))
    End Sub
End Class


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info/

Don't forget to read my blog at http://weblogs.asp.net/mschwarz/

The open source project is now located at 
http://www.codeplex.com/Wiki/View.aspx?ProjectName=AjaxPro
-~----------~----~----~----~------~----~------~--~---

Reply via email to