Sunday, April 27, 2014

Toad how to test Stored Procedure with return values (how to see result)

if you have stored procedure return single or multiple values separately not in cursor you can't see the stored Procedure Result

follow the following steps
1- right click on you stored procedure that returns single values as output parameters
2-Click Execute Procedure
3-Copy Code Generated in execute window and paste it to new Editor
4-Right Click On Script Output panel and check DBMS output

5-after Execute Line write the flowing
 DBMS_OUTPUT.PUT_LINE('DESCRIPTION TEXT ' || TO_CHAR(YOUR_OUTPUT_VAR));
EXAMPLE:
DECLARE   P_SEGELNO VARCHAR2(200);  P_ORDERNO VARCHAR2(200);  P_ORDDATEH VARCHAR2(200);  P_BEGDATEH VARCHAR2(200);  P_PERIOD NUMBER;  P_ENDDATEH VARCHAR2(200);  P_EMP_NAME VARCHAR2(200);  P_MESSAGE_TEXT VARCHAR2(200);
BEGIN   P_SEGELNO := '1073286849';  P_ORDERNO := NULL;  P_ORDDATEH := NULL;  P_BEGDATEH := NULL;  P_PERIOD := NULL;  P_ENDDATEH := NULL;  P_EMP_NAME := NULL;  P_MESSAGE_TEXT := NULL;
  SHR.NET_EMP_MULTI.NOT_ALLOW_EXTEND ( P_SEGELNO, P_ORDERNO, P_ORDDATEH, P_BEGDATEH, P_PERIOD, P_ENDDATEH, P_EMP_NAME, P_MESSAGE_TEXT );    DBMS_OUTPUT.PUT_LINE('ORDER NUMBER = ' || TO_CHAR(P_ORDERNO));     DBMS_OUTPUT.PUT_LINE('ORDER DATE = ' || TO_CHAR(P_ORDDATEH));    DBMS_OUTPUT.PUT_LINE('ORDER PERIOD = ' || TO_CHAR(P_PERIOD));    DBMS_OUTPUT.PUT_LINE('ORDER ENDDATEH = ' || TO_CHAR(P_ENDDATEH));    DBMS_OUTPUT.PUT_LINE('EMP NAME = ' || TO_CHAR(P_EMP_NAME));    DBMS_OUTPUT.PUT_LINE('EMP NAME = ' || TO_CHAR(P_MESSAGE_TEXT));      COMMIT; END; 

6-Click on DBMS or Press Keyboard ALT_CTR_D
you should see your result


Toad for Oracle arabic problem when run queries [solved]

1- change your NLS_Lang registry key to
AMERICAN_AMERICA.AR8MSWIN1256

do this for all oracle homes in windows.

2- change your windows Region and Language Format to arabic (egypt ) or saudi araia

you should run queries now fine.

if you solve NLS_Lang problem toad will not work untill set your format to arabic this is stupid issue.


Friday, April 25, 2014

SQL SERVER CHECK PARAMETER TEXT LENGTH EXAMPLE

BEGIN
DECLARE @RESULT VARCHAR(50)
DECLARE @JOB_TITLE_ID NVARCHAR(50)
SET @JOB_TITLE_ID ='';
IF(
(SELECT LEN(@JOB_TITLE_ID))>0)
SET @RESULT ='GREATER THAN ZERO'
ELSE
SET @RESULT = 'LESS OR EQUAL ZERO'
SELECT @RESULT;
END

Wednesday, April 23, 2014

backup IIS Configuration for server - How to Copy windows Server 2008 IIS Configurations

How to Copy windows Server 2008 IIS Configurations
TO TAKE FULL BACKUP FOLLOW THE LINK BELOW
http://blogs.iis.net/bills/archive/2008/03/24/how-to-backup-restore-iis7-configuration.aspx
---------------------------------------------------------------------------------------------------------------------
How to copy IIS configuration from existing server to new one 
I'd say export your config
In IIS manager, you need to export the config from server 1. In IIS manager, click the Server node, and go to Shared Configuration under Management and Click “Export Configuration”. You can use a password if you are sending them across the internet, if you are just gonna move them via a USB key then don't sweat it.
Move these files to your new server
administration.config
applicationHost.config
configEncKey.key
On the new server, go back to the “Shared Configuration” section and check “Enable shared configuration.” Enter the location in physical path to these files and apply them.
It should prompt for the encryption password(if you set it) and reset IIS.
BAM! Go have a beer!

using wizard to export IIS configuration you should install web deploy tool
http://www.iis.net/learn/publish/using-web-deploy/use-the-web-deployment-tool
source
http://technet.microsoft.com/es-es/library/dd569059(v=ws.10).aspx
----------------------------------------------------------------------------------------------------------------
To run commands using Command Prompt use the following commands.
Run Command Prompt with administration Privileges.

To Export the Application Pools on IIS 7 :
%windir%\system32\inetsrv\appcmd list apppool /config /xml > c:\apppools.xml
This will export all the application pools on you’re webserver, therefor you need to edit the apppools.xml and remove the application that you do not need to import for example:
  • DefaultAppPool
  • Classic .NET AppPool
  • SecurityTokenServiceApplicationPool
And other apppools that already exist on the second webserver, appcmd doesn’t skip already existing apppools, it just quit’s and doesn’t import any.
To import the Application Pools:
%windir%\system32\inetsrv\appcmd add apppool /in < c:\apppools.xml
All the AppPools in the xml will be created on you’re second webserver.
To Export all you’re website:
%windir%\system32\inetsrv\appcmd list site /config /xml > c:\sites.xml
This will export all the websites on you’re webserver, therefor you need to edit the sites.xml and remove the websites that you do not need to import for example:
  • Default Website
And all other websites that already exist on the second webserver.
To Import the website:
%windir%\system32\inetsrv\appcmd add site /in < c:\sites.xml
It’s also possible to export a single website or application pool all you need to do is add the name of the Application Pool or Website to the command line:
To export/import a single application pool:
%windir%\system32\inetsrv\appcmd list apppool “MyAppPool” /config /xml > c:\myapppool.xml
Import:
%windir%\system32\inetsrv\appcmd add apppool /in < c:\myapppool.xml
To export/import a single website:
%windir%\system32\inetsrv\appcmd list site “MyWebsite” /config /xml > c:\mywebsite.xml
Import:
%windir%\system32\inetsrv\appcmd add site /in < c:\mywebsite.xml


Sunday, April 20, 2014

Microsoft Outlook 2010 separate mails from sender to separated Folder

http://office.microsoft.com/en-us/outlook-help/create-a-rule-based-on-email-message-sender-or-recipients-HA102063132.aspx

STEPS :
1- OPEN HOME TAB
2-CLICK ON RULES FOLDER
3-CREATE NEW RULE
4- CHOOSE FROM SENDER OR MESSAGE TITLE AND NEXT TO COMPLETE CONFIGURAITONS

Saturday, April 19, 2014

Gridview format date string using string.format

example

    <asp:TemplateField HeaderText="من تاريخ">
                                                                    <ItemTemplate>
                                                                        <asp:Label runat="server" ID="LBLhIKELTEXT" Text='<%# String.Format("{0:yyyy/MM/dd}", Eval("FROM_DATE")) %>'></asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateField>


Tuesday, April 15, 2014

generate gridview row index for the first column

   <asp:TemplateField HeaderText="مسلسل">
                                        <ItemTemplate>
                                            <%# Container.DataItemIndex + 1 %>
                                        </ItemTemplate>
                                    </asp:TemplateField>

Monday, April 14, 2014

asp.net user control multiple instances javascript Problem on the page

http://www.aspsnippets.com/Articles/Issue-JavaScript-in-WebUserControl-not-working-when-used-multiple-times-on-same-page.aspx

Passing COMMA SEPARATED LIST into an IN clause within a SQL function


Passing a string directly into the IN clause is not possible. However, if you are providing the list as a string to a stored procedure, for example, you can use the following dirty method.
First, create this function:

CREATE FUNCTION [dbo].[fnNTextToIntTable] (@Data NTEXT)
RETURNS 
    @IntTable TABLE ([Value] INT NULL)
AS
BEGIN
    DECLARE @Ptr int, @Length int, @v nchar, @vv nvarchar(10)

    SELECT @Length = (DATALENGTH(@Data) / 2) + 1, @Ptr = 1

    WHILE (@Ptr < @Length)
    BEGIN
        SET @v = SUBSTRING(@Data, @Ptr, 1)

        IF @v = ','
        BEGIN
            INSERT INTO @IntTable (Value) VALUES (CAST(@vv AS int))
            SET @vv = NULL
        END
        ELSE
        BEGIN
            SET @vv = ISNULL(@vv, '') + @v
        END

        SET @Ptr = @Ptr + 1
    END

    -- If the last number was not followed by a comma, add it to the result set
    IF @vv IS NOT NULL
        INSERT INTO @IntTable (Value) VALUES (CAST(@vv AS int))

    RETURN
END
(Note: this is not my original code, but thanks to versioning systems here at my place of work, I have lost the header comment linking to the source.)
Then use it like so:
SELECT  *
FROM    tblMyTable
        INNER JOIN fnNTextToIntTable(@MyList) AS List ON tblMyTable.ID = List.Value
EXAMPLE FOR STORED USING FUNCTION

CREATE PROCEDURE [dbo].[USERS_SEARCH]
@USER_ID INT = NULL,
@USER_NAME NVARCHAR(50)=NULL,
@USER_FULL_NAME  NVARCHAR(500) = NULL,
@DEPARTMENT_ID INT = NULL ,
@SECTION_ID INT = NULL ,
@DIVISION_ID INT = NULL ,
@CLINIC_ID INT = NULL ,
@JOB_TILE_ID VARCHAR(50) = NULL 
AS
BEGIN
DECLARE @DOCTORS_JOB_TITLE_ID INT = 2;
DECLARE @ACTIVE_USER INT =1;
--IF POSITION IS DOCTORS SO WE WILL GET ALL EMPLOYEES WHO JOB ID IS DOCTOR ALSO
BEGIN
SELECT DISTINCT USER_ID,JOB_TITLE_ID,POSITION_ID, USER_FULL_NAME  ,USER_NAME,
USER_FULL_NAME_EN , DEPARTMENT_ID,SECTION_ID,DIVISION_ID ,CLINIC_ID ,
DBO.DEPARTMENT_GETNAMEBYID(DEPARTMENT_ID) AS DEPARTMENT_NAME,
DBO.CLINIC_GETCLINIC_NAMEBYID(CLINIC_ID) AS CLINIC_NAME,
DBO.SECTION_GETNAMEBYID(SECTION_ID) AS SECTION_NAME,
DBO.DIVISION_GETNAMEBYID(DIVISION_ID) AS DIVISION_NAME
FROM   [DBO].[USERS]
WHERE (@USER_ID IS NULL OR USER_ID =@USER_ID) AND
  (@USER_FULL_NAME IS NULL OR USER_FULL_NAME_EN LIKE '%'+@USER_FULL_NAME+'%' OR USER_FULL_NAME LIKE '%'+@USER_FULL_NAME+'%') AND
  ( @DEPARTMENT_ID IS NULL OR   DEPARTMENT_ID=@DEPARTMENT_ID)AND
  ( @SECTION_ID IS NULL OR   SECTION_ID=@SECTION_ID)AND
  ( @DIVISION_ID IS NULL OR   DIVISION_ID=@DIVISION_ID)AND
  ( @CLINIC_ID IS NULL OR   CLINIC_ID=@CLINIC_ID)AND
  (@JOB_TILE_ID IS NULL OR JOB_TITLE_ID IN (SELECT Value  FROM COMMA_SEPARATED_LIST_TO_INT_TABLE(@JOB_TILE_ID)))
  AND ( STATUS_ID=@ACTIVE_USER);
END;
END;

Tuesday, April 8, 2014

help files create tools , user manual tools

http://www.ewoodruff.us/shfbdocs/?topic=html/bd1ddb51-1c4f-434f-bb1a-ce2135d3a909.htm#

http://msdn.microsoft.com/en-us/library/windows/desktop/ms670169(v=vs.85).aspx

http://sourceforge.net/projects/ndoc3/

http://www.helpndoc.com/download

http://citylan.dl.sourceforge.net/project/helpmaker/helpmaker/v7%20build%2070/sf.zip

Thursday, April 3, 2014

Microsoft patterns & practices Guidance Explorer for Coding Standard Best Practice



patterns & practices Guidance Explorer
The patterns & practices Guidance Explorer
"is a tool that enables discovery, composition and consumption of high quality development guidance. Guidance Explorer installs with a connection to the patterns & practices guidance library including performance and security topics for .NET, ASP.NET, and ADO.NET applications. The guidance library contains a variety of guidance types including checklists and guidelines covering design, implementation and deployment topics."
So, this will be a bit friendlier than one big document and will let you:
  • Find relevant patterns & practices guidance
  • Build customized checklists for your development scenarios
  • Build customized guidelines for your development scenarios
  • You can build custom sets of guidance and share with your team as recommended practice.
  • Subscribe to an RSS feed of guidance
http://guidanceexplorer.codeplex.com/