Friday, December 26, 2014

How to make a copy of a existing database into new database

This feature is not available in Express version.

Right Click on database -> Task -> Copy Database.

It will open a wizard you have to follow, where you will have to select the source database and enter a new database name to copy whole database objects into the newer one.

Saturday, August 30, 2014

How to round to the nearest whole number in C# ?

I have Googled for it and found some interesting answers:

My problem was solved by simple using on Math.Ceiling

var wholeNumber = (int)Math.Ceiling(fractionalNumber);

And other interesting answers are :

Math.Ceiling
always rounds up (towards the ceiling)
Math.Floor
always rounds down (towards to floor)


References :

Friday, August 22, 2014

Microsoft Report Viewer Print Button not Working / Visible in IE 10 & 11


I had created report in on of my client website using "Microsoft Report Viewer Control" but a very known problem with Report Viewer is Printing is not possible in other browser instead of Internet Explorer.

Today I have faced a new problem that Print Button is not visible in IE 11 when Client updated their  Windows 8 to Windows 8.1. 



Then I started goggling and Finally I found  that it's happens because of Active X. And I followed these steps give below.

  •  Start Windows Internet Explorer.
  • On the Tools menu, click Internet Options.
  • On the Security tab, click Local Intranet, and then click Sites
  • Click Advanced.
  • Type the URL of your site in the Add this website to the zone box, and then click Add.  (in development mode it will be http://localhost)
  • Click Close to close the Local Intranet dialog box, and then click OK.
  • On the Security tab, click Custom Level.
  • Click Enable for each component that is listed under ActiveX controls and plugins.
  • Click OK to close the Internet Options dialog box.
  • Restart Internet Explorer
  • Try printing the report.

It's working fine now !!!.

Hope it will help you. :)

Friday, May 9, 2014

Maintain Scroll Position on Postback in ASP.NET

After a long time googling I have got a good solutions to maintain scroll position. See the post given below.

This article shows how to allows pages to automatically maintain the current scroll position across postbacks.
The MaintainScrollPositionOnPostback page directive attribute allows to do that.
This feature is useful for large pages where scrolling is necessary to view input controls down further on the page.
There are three ways of applying the property to a web page.

  1. You can set it programmatically 
    Page.MaintainScrollPositionOnPostBack = true;
  2. In the page declaration 
    <%@ Page MaintainScrollPositionOnPostback="true" %>
  3. Or in the web.configs <system.web> section. 
    <pages maintainScrollPositionOnPostBack="true" />
I have used 3 point & It's working absolutely fine.
 
This feature is an absolute must-have on large web pages built for postback scenarios.
A simple but very useful feature.

Smartnavigation = true  implemented the same feature in 1.1 framework SmartNavigation only had "issues" and it only worked in IE but the new MaintainScrollPositionOnPostback apparently works in most common browsers.


Monday, March 31, 2014

Generate a unique alphanumeric password using SQL



DECLARE @PwdLen SMALLINT,
@Chr TINYINT,
@Password VARCHAR(20)

-- Seed
SET @Chr = RAND(DATEPART(ms, GETDATE())) * 0
SET @Password = ''

SET @PwdLen = 1
WHILE @PwdLen < 8
BEGIN
SET @Chr = RAND() * 62
SET @Password = @Password + CHAR(
CASE WHEN @Chr < 10 THEN @Chr + 48 
WHEN @Chr BETWEEN 10 AND 35 THEN @Chr + 55 
ELSE @Chr + 61 
END)

SET @PwdLen = @PwdLen + 1
END

SELECT @Password [Password]

Wednesday, March 19, 2014

SQL statement which will give me all the days of a given month as individual rows

Hi friends,

I have searched a lot in Google and finally I found that its too easy to get the result. Check the query given below.

DECLARE @month    INT
DECLARE @year    INT
SET @month=2
SET @year = 2016

SELECT CAST(CAST(@year AS VARCHAR) + '-' + CAST(@Month AS VARCHAR) + '-01' AS DATETIME) + Number 'date'
FROM master..spt_values WHERE type = 'P'
AND
(CAST(CAST(@year AS VARCHAR) + '-' + CAST(@Month AS VARCHAR) + '-01' AS DATETIME) + Number )
<
DATEADD(mm,1,CAST(CAST(@year AS VARCHAR) + '-' + CAST(@Month AS VARCHAR) + '-01' AS DATETIME) )

 

Saturday, February 22, 2014

Last modified Tables & Stored Procedures details in Microsoft SQL Server

Let's find out the last modified Tables & Stored Procedures details in MSSQL by writting a simple Query.

For User Tables
SELECT * FROM sys.objects WHERE type='U' ORDER BY modify_date DESC

For Stored Procedures
SELECT * FROM sys.objects WHERE type='P' ORDER BY modify_date DESC

These Queries fetching records from system object table order by last modified date & time.  

Friday, February 21, 2014

Enable remote connections for SQL Server Express 2012

  1. Run SQL Server Configuration Manager.
  2. Go to SQL Server Network Configuration > Protocols for SQLEXPRESS.
  3. Make sure TCP/IP is enabled.
So far, so good, and entirely expected. But then:
  1. Right-click on TCP/IP and select Properties.
  2. Verify that, under IP2, the IP Address is set to the computer's IP address on the local subnet.
  3. Scroll down to IPAll.
  4. Make sure that TCP Dynamic Ports is blank. (Mine was set to some 5-digit port number.)
  5. Make sure that TCP Port is set to 1433. (Mine was blank.)
(Also, if you follow these steps, it's not necessary to enable SQL Server Browser, and you only need to allow port 1433, not 1434.)

Monday, January 27, 2014

Files on External/Flash Drive Changed to Shortcuts Virus

Issue

I caught a virus on my flash drive at work and it appears to have changed all my file names to short cuts. I believe I’ve cleaned the virus but how do i get my files back so that I can view them?

Solution

  1. If you did not format your flash drive, then check whether the files are not in hidden mode.
  2. Click on “Start” –>Run–>type cmd and click on OK.
  3. Check your external Drive letter in My Computer
  4. Here I assume your external drive as G:
  5. Enter this command.attrib -h -r -s /s /d g:*.* 
  6. Delete the unnecessary shortcuts.
Note: Replace the letter g with your flash drive letter.
Still problem? Write down in comments section.