Sunday 12 November 2017

Tuesday 31 October 2017

How to search in sql for arabic names

When you create table contains name and you want to search about 'إبراهيم', or 'أحمد', no result will return,
to overcome this problem create another field and update it by no Hamza as the following, search in the new field and the original field

update StudentInfo
  set FullNameWithoutHamza= REPLACE(REPLACE(FullName,N'إ',N'ا'),N'أ',N'ا')


In select
where FullName like N'%'+@StudentName+'%' or FullNameWithoutHamza like N'%'+@StudentName+'%'

Wednesday 25 October 2017

asp connect to sql and access

Monday 27 February 2017

ASP Web Service

Sometimes you need to create a webservice .asmx, without use service reference and call this service via ajax request or other requests, you need to do the following


  • Right click on any folder you want to add the service to it and type the name of it.

  • After you hit OK, your code should locks like the following 
namespace ...
{
    ///
    /// Summary description for WebService1
    ///
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    [System.Web.Script.Services.ScriptService]
    public class WebService1 : System.Web.Services.WebService
    {

        [WebMethod(EnableSession = true)]// This to make this method accessible to public and access the web session in the link  
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]// to return the text as json
        public string HelloWorld(string x1, int x2)
        {
            return "Hello World";
        }
    }
}
  • To call HelloWorld method from jquery use the following code snippet 
      var x1='xxx', x2=20;    
 $.ajax({
            type: "POST",
            url: "/WebService1.asmx/HelloWorld",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: "{x1:'"x1+ "', x2:'" + x2"'}",
            beforeSend: function () {
                $('#loadingImage').show();//to show a loading image while ajax call in progress
            },
            success: function (data) {
                console.info(data.d);
            },
            complete: function () {
                $('#loadingImage').hide();
            },
            error: function (XMLHttpRequest, result, errorThrown) {
                console.info('error',errorThrown);
            }
        });