Monday, 5 February 2018

DefaultConnection in new Project in ASP using templates

after you have created the project you have to create new user account, after that you will see the .mdf and .ldf files in App_Data folder

Sunday, 4 February 2018

SQL Training - 01

Schema: is a description of the data 
schema is SQL is a group of tables 
you can create a user and give him a schema; this user can't see any other tables from sachems

SQL Server Databases:
  1. Master: contains meta of all dbs 
  2. Temp:
  3. Model: Like polymorphism (Create tables (Like Lookups), views, stored procedures,... to be inherited in and newly created database)
  4. Ms: It contains Jobs, Alerts,
  5. Resource
  6. Distribution 
You mustn't make any changes in Master and MS databases


Default Collations for Arabic:

Use Arabic_100_CI/CS_AS_KS_WS after that you don't need to use nvarchar as datatypes you can use varchar to store arabic values 

* You can create multi-files(.nDF) to store tables, each table could be stored in different group, for example create A1.nDF, A2.nDF files as group, and put table T1 in group 1
* Not recommend to use Shrink in database but still you can use it. 

Views:
  • Lite
  • Executed
  • Ready to read
  • High performance and low time to execute
  • Separated Privileges
  • Denormalization 
  •  No parsing needed after created

Sunday, 12 November 2017

SQL Update Table From Table

update ORIGINAL
set  Field=wt.Field
from WHRETable wt
where ORIGINAL.PrimaryField= wt.PrimaryField

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);
            }
        });

Wednesday, 16 November 2016

haier tv and minix

When you open Full HD video (1080p) on some Haier TVs the screen will keep flashin, sometime show and some time blue screen

to overcome this problem, go to settings>Playback settings > HDMI self-adaption> choose level 1 not level 2