dcsimg
Results 1 to 2 of 2

Thread: data search by 2 or more

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2015
    Posts
    102

    data search by 2 or more

    hello

    am trying make new search autocomplete its only work with English font ,how about Arabic font not working with UTF-8? , also adding name and civil id like my old search data .
    i did try but nothing change
    any help please!



    first one my old code for search data
    Code:
       string mainconn = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
                SqlConnection sqlconn = new SqlConnection(mainconn);
                sqlconn.Open();
                SqlCommand sqlcomm = new SqlCommand();
                string sqlquery = "Select * from [dbo].[Table_infoname] where name LIKE '%' + @name +'%' OR civilid LIKE '%' + @civilid +'%' ";
    
                sqlcomm.CommandText = sqlquery;
                sqlcomm.Connection = sqlconn;
                sqlcomm.Parameters.AddWithValue("name", TextBox1.Text);
                sqlcomm.Parameters.AddWithValue("civilid", TextBox1.Text);
    
                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter(sqlcomm);
    
                sda.Fill(dt);
    
                sqlcomm.ExecuteNonQuery();
    the second its for autocomplete
    Code:
    [WebMethod]
            public static List<string> GetEmp(string empdetails)
            {
                List<string> emp = new List<string>();
    
                string mainconn = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
                SqlConnection sqlconn = new SqlConnection(mainconn);
                string sqlquery = string.Format("Select name from [dbo].[Table_infoname] where name LIKE '%{0}%'", empdetails);
                sqlconn.Open();
    
                SqlCommand sqlcomm = new SqlCommand(sqlquery, sqlconn);
                SqlDataReader sdr = sqlcomm.ExecuteReader();
    
                while (sdr.Read())
                {
                    emp.Add(sdr.GetString(0));
    
                }
                sqlconn.Close();
                return emp;
    
            }
    behind code with scrip
    [CODE]
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="gsc.WebForm5" Culture="ar-KW" UICulture="ar-kw" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>


    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-1.8.0.js"></script>
    <script src="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.js"></script>
    <script>
    $(function () {
    $("#TextBox1").autocomplete({
    source: function (request, response)
    {
    var param = { empdetails: $('#TextBox1').val() };

    $.ajax({
    url: "WebForm5.aspx/GetEmp",
    data: JSON.stringify(param),
    type: "post",
    contentType: "application/json; UTF-8",
    datafilter: function(data) { return data; },
    success: function (data) {
    response($.map(data.d, function (item) { return { value: item } }))

    },
    });
    },
    minLength:3
    });
    });
    </script>
    </head>

    <body>
    <form id="form1" runat="server">
    <center>
    <asp:TextBox ID="TextBox1" runat="server" Font-Bold="True" Font-Size="16pt" Height="26px" Width="319px" Font-Names="Arial" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
    <br />
    </center>

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    </form>
    </body>
    </html>%
    Attached Images Attached Images  
    Last edited by kankon; Sep 28th, 2019 at 12:09 PM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2015
    Posts
    102

    Re: data search by 2 or more

    update1 : when i try search by civilid work show me the Arabic font , when i type Arabic font still not working
    Code:
                string sqlquery = string.Format("Select name,civilid from [dbo].[Table_infoname] where name LIKE '%{0}%' OR civilid LIKE '%{0}%'", empdetails);
    Name:  Annotation 2019-09-28 200003.png
Views: 42
Size:  4.4 KB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width