TechBubbles

Archive for the 'Tips & Solutions' Category

T-SQL TIP in SQL Server 2008

You love this if you write a lot of T-SQL code. This tip I can say as  T-SQL language syntax enhancement. The following are the enhancements in T-SQL

  1. Now We can declare and initialize the variables with single statement.

Read more

Related Posts:

No comments

Remote Desktop Sessions from Commandline

You will commonly see the following error message when you try to connect windows 2003 server using RemoteDesktopConnection.

“The terminal server has exceeded the maximum of allowed connections ”

logon-exceeded

 

You can disconnect the other remotely logged in users if you are a domain Admin user. Most of the users some time not even be using the sessions.

To see the list of remote sessions in the command window, type the following command.

qwinsta /server:<ServerIP>

Example:

qwinsta /server: 192.168.219.2

Remote sessions list

Read more

Related Posts:

  • No Related Posts
No comments

Solution for Office 2007 application project system could not be enabled

When you first time creating a Office 2007 application using VS 2008 you may get the following error.

“Programmatic access to the Microsoft Office Visual Basic for Applications project system could not be enabled”

The Error looks like the following window

ErrorScreen

The solution for the above error is

1. Open the MS Word or MS Excel

2. Go to Tools Menu then select Macro then click security option

3.Click on the Trusted Publishers Tab

4.Select the check box next to Trust access to Visual Basic Project, then say OK

5.Close all the Office applications and then try to create a new office application.

I got this solution from the following link .

Related Posts:

  • No Related Posts
No comments

Calculating the size of the File in C#

Introduction

This code snippet explains how to calculate the size of the file and display in a label control. For example I am taking PDF file to find the size. It Displays the size of the file in Bytes, Kilobytes and Megabytes.

 

//Calculate size of the PDF file
       if (PdfFilePath.EndsWith("pdf"))
       {
           FileInfo info = new FileInfo(PdfFilePath);
           long fileSize = info.Length;
           string strFileSize = FormatFileSize(fileSize);
           lblFileSize.Text = strFileSize;
        }

Read more

Related Posts:

4 comments

Working with Configuration files

Introduction

Configuration files are central place to configure your web or windows applications. The web.config file is used for configuring the web applications and app.config for windows applications.

The ASP.NET Application comes with web.config file with default configuration sections and you can easily manage them at the intialstage of the project development. As soon as your project grows mature, web.config file turns out to be a huge file.

The configuration files can be different from development environment to production environment.

Example: Connection strings, Application settings, logging and compilation settings are differed from development to production environment.

Maintaining multiple configuration files is pain to manage, For this .NET configuration system has a feature that each configuration section can define an attribute named “configSource”  to define an alternative location from where the configuration file has to be loaded.

Example: In web.config file locate the connectionStrings section and add a new attribute name configSource and give the value as “MyConnectionStrings.config”.

   1: <connectionStrings configSource="MyConnectionStrings.config"/>

Add a new file called “MyConnectionStrings.config” to the same directory where web.config lives and define its contents as follows:

   1: <?xml version="1.0"?>

   2: <connectionstrings>

   3:     <add name="MyDataBase" connectionstring=” ”/> 

   4: <connectionstrings>

Key points:

  • External configuration file must contain the section name as the root element.
  • If you use configSource you must not define any other attribute or child element for the respective section in the web.config file.
  • It is useful if you move all your configuration files to subfolder to keep root directory clean.    

Related Posts:

1 comment

Configuring .NET Framework 1.1 on windows vista

Configuring .NET FW v1.1 on Windows vista is bit tricky.

Here are the steps you need to follow

  • Download .NET Fx from .NET FW v1.1 because by default vista come up with .NET FW v2.0 and v3.0.

If you install FW v1.1 alone at the end of installation you will get the following error

                   RegSvcs.exe – Common Language Runtime Debugging Services

                     ——————————-

                     Application has generated an exception that could not be handled.

                     Process id=0×9a0 (2464), Thread id=0xf70 (3952).

                     Click OK to terminate the application.

                     Click CANCEL to debug the application.

                    —————————

                   OK   Cancel  

                   —————————

The above error is in .NET FW v1.1 which is  known to occur on window vista.

This issue is resolved in  Microsoft .NET FW 1.1 SP1, however you will need to use the following procedure

  • Download .NET FW v1.1 SP1 .
  • Save both installations to the same directory.
  • Ensure that FW 1.1 Redistributable package name is dotnetfx.exe.If not change its name to dotnetfx.exe
  • Ensure that FW 1.1 SP1 is named dotnetfxsp1.exe. If not change its name to dotnetfxsp1.exe
  • Run the following 3 commands using the order shown

  dotnetfx.exe /c:”msiexec.exe /a netfx.msi TARGETDIR=C:\<DirectoryName>”

  dotnetfxsp1.exe /Xp:C:\<DirectoryName>\netfxsp.msp

  msiexec.exe /a c:\<DirectoryName>\netfx.msi /p                                         c:\<DirectoryName>\netfxsp.msp  

  • Install both Microsoft .Net Framework 1.1 and Service Pack 1 by running C:\<DirectoryName>\netfx.msi

Related Posts:

2 comments