Wednesday, June 10, 2015

How to Completely hide windows Form

If you are thinking about how to completely hide your Windows Form Application, so that it will run silently in the background without anyone knowing about it.

To do that add the following code

        protected override void OnLoad(EventArgs e)
        {
            Visible = false;
            ShowInTaskbar = false;
            base.OnLoad(e);
        }

This code will completely hide your form at startup.

I hope it was informative for you and I would like to Thank you for reading.

Sunday, May 10, 2015

Add Leading Zero in Excel

If you want to add leading zero's in your excel column so that your value become like following

123 > 0123
9827 > 09827
0000 > 0000

1. Select the column on which you want to apply this setting, and click Ctrl + 1

This will open Format Cell's dialog box



2. For the Category Select Custom

Now lets assume you need to enter 01234

3. So in type column just type 000#, and click on OK

That's it now if you enter 01234 in that column excel will accept it, and will not remove leading zero
I hope it was informative for you and I would like to thank you for reading.

Sunday, May 3, 2015

IF NOT EXISTS For Sql Functions

You must have used IF NOT EXISTS for DML operation, but the same method doesn't work for sql function.

In this tutorial I'm gonna show you how to use IF NOT EXISTS to create a function if it is already not created.

Download .Sql file for this project from HERE
 
IF EXISTS (SELECT * FROM [dbo].[sysobjects]
           WHERE ID = object_id(N'[dbo].[myfunction]')
                 )
    DROP FUNCTION [dbo].[myfunction]
GO

create function myfunction()
 returns int
 as
   begin
       return 5+4;
   end   

The idea here is to check if the function exists, if it exists than we will first drop it, and after that we can create the function.

I hope it was informative for you and I would like to Thank you for reading.

Wednesday, April 15, 2015

Sql Stored Procedure



  • Syntax for creating Procedure
  • We can insert row using SP
  • W can delete rows using SP
  • We can change Data Type of any column using SP
  • We can drop same table of which we are executing the SP
  • Stored Procedure can accept parameters
  • Triggers will be called from SP
  • Trigger will be called  even if there were no action took place of Delete Sql statement written in SP
  • Create procedure must be the first line in the batch this is why we have to use GO keyword
Syntax for creating procedure without Parameter
GO

CREATE PROCEDURE Your Procedure Name
AS
  BEGIN
      SELECT *
      FROM   Your Table Name
  END


Syntax for creating procedure with Parameter

CREATE PROCEDURE Myproc1 @ID   INT, @name VARCHAR(20)
AS
    SELECT *   FROM   test1    

        WHERE  empid = @ID   AND NAME = @name 
 

Friday, April 3, 2015

How to Install exe as a Windows Service

In this tutorial I will show you how to install a exe as a windows services.

For this I have created a simple exe in Visual studio 2010 you can create it in any version of Visual Studio.

1. Open up your command prompt
2. Type the following line in CMD

sc create Service_Name binPath= "Exe Path"

3. Replace Service_Name with your service name and ExePath with your exe path with quotes

Example

sc create MyService1 binPath= "c:\Taqi.exe"

I hope it was informative for you and I would like to Thank you for reading.