locked
Asp..Net Ajax Autocomplete RRS feed

  • Question

  • User197255166 posted

    Hello friends I have a problem. I take clients through TextBox AutoComplete Ajax. But here when I want also want to attract customers, also that which users belong to this customer. How is this possible. I share code. Can anyone help me please.

    Here I get data with inner join.

    string sql = string.Format("SELECT Title,Name FROM Customer LEFT JOIN User As T3 ON T3.Id = Customer.IdSaler 
    WHERE Title like '%{0}%' Order BY Title LIMIT 10", text);

    Here is Html Page Ajax Code

    <script>
            $(function () {
                $("#txtCustomer").autocomplete({
                    minLength: 3,
                    source: function (request, response) {
                        $.ajax({
                            url: "API.ashx",
                            data: 'Token=GetCustomersForAutoComplete&Param1=' + request.term,
                            dataType: "json",
                            success: function (data) {
                                response(data);
                            }
                        });
                    },
                    select: function (event, ui) {
                        $("#txtCustomer").val(ui.item.Title);
                        $("#hdnCustomer").val(ui.item.CustomerId);
                        return false;
                    }
                }).autocomplete("instance")._renderItem = function (ul, item) {
                    return $("<li>").append(item.Title + "-" + item.Name).appendTo(ul);
                };
            });
        </script>

    Sunday, May 22, 2016 1:13 PM

Answers

  • User1724605321 posted

    Hi Aliyilmaz,

    So your question is how to get data with inner join in ado.net ? ADO.NET runs straight SQL queries. try to below sql query :

    SELECT column_name(s)
    FROM table1
    INNER JOIN table2
    ON table1.column_name=table2.column_name;
    
    or:
    SELECT column_name(s)
    FROM table1
    JOIN table2
    ON table1.column_name=table2.column_name;

    You could try your query in SSMS to check whether it is correct .

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 31, 2016 2:52 AM

All replies