Guidelines to handle Db connection

Please confirm that you close the original connection to a database all the time and that you are using connection pooling to get better processing speed of database connection creation etc. Here are some tips for you:

1. Use web.config to store up the connection string:

2. Use this connection string forever and do not make any changes to it. If you were not doing this (for example using different DSNs) you will disable the connection pooling feature:
string dsn = System.Configuration.ConfigurationSettings.AppSettings[“dsn”];

3. Do not perform any tricks to try to deal with connections etc, just proceed and use it (no wrapper classes or so involved):
SqlConnection conn = new SqlConnection(dsn);

4. Formulate the time between conn.Open() and conn.Close() as small as possible. E.g. don’t do this:
SqlConnection conn = new SqlConnection(dsn);
Conn.Open();
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.Add(…);

//and further cmd parameters actions and so on

SqlDataReader reader = cmd.ExecuteReader();

//use the reader and do a bundle of additional tasks, not relying on the database

conn.Close();

But rather, use:
SqlConnection conn = new SqlConnection(dsn);
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.Add(…);

//and more cmd parameters actions etc

conn.Open();
SqlDataReader reader = cmd.ExecuteReader();

//use the reader
conn.Close();
//perform a batch of other work, not relying on the database

5. Always close the connection when you are done, even when an exception occurs. To do this, use the try…finally pattern:
SqlConnection conn = new SqlConnection(dsn);
try
{
//some init depending on conn
conn.Open();
//minimum number of lines of code depending on the open connection
}
finally
{
if (conn.ConnectionState == ConnectionState.Open)
conn.Close();
}
or the using pattern in C#:
using (SqlConnection conn = new SqlConnection(dsn))
{
//…
conn.Open();
}
This will close the db connection repeatedly while leave from the using block.

TAGS:

Copy to Clipboard with Javascript on Mozilla or Netscape Browsers

Hope all may know that by using Javascript select() and execCommand(“Copy”)
function we may able to select all the contents and copy those selected contents into our clipboard.

However, this function will work only in Internet Explorer (all version) by default, but not in Mozilla or Netscape browsers. To enable these Javascript Copy to Clipboard function in the Mozilla and Netscape Browsers, please follow the steps to provided below

1) Type about:config in the browser address bar.
2) Now, in the Filter window search for the following:
signed.applets.codebase_principal_support
3) Set the Boolean value to true for Firefox or enter true or 1 for Mozilla browsers.
Keep in mind that Preference names are case-sensitive.

Once you have made this simple settings on your Mozilla or netscape browsers you may use the copy to clipboard function on your browsers.

TAGS:

Cannot able to close Form?

It is a fascinating bug that forces a Windows Form to go into a condition where it cannot be closed. Are you using the initial version of the .NET framework with SP1 installed?
Want to check this?

  • Build a new form, F1.
  • Set a user control U1 on top of it.
  • Locate one more user control, U2, onto the control U1.
  • To end with, put a button onto U2.
  • Write down an event handle for the button click that causes the user control U2 to be detached from its parent, U1.
  • Run the application.
  • Click on the button.
  • You should wind up with a form.
  • Now make an attempt to close the form by clicking on the close button.
  • It does not work. Am I right?
    Reason:
    The form is saying NO to close because its Close method is trying to authenticate the control first. The validation should fail because its unvalidatedControl private member still points to the button which has been detached from the hierarchy.

    How to overcome:
    After get rid of the user control U2, call a.OnControlRemoved (c) that clear the unvalidatedControl variable.

TAGS:

CGI Time Out The specified CGI application exceeded the allowed time for processing. The server has deleted the process.

Whenever we tried to run some large script like data extraction or trying to get thousand number of records from remote database, most of us will face the following CGI Issue

“The specified CGI application exceeded the allowed time for processing. The server has deleted the…”

In order to run your script without any such kind of issue, please follow the steps provided below. Earlier I too faced such a issue but after research in my PC I finally fixed it.

Note: the following steps is only suitable only for the Windows XP and with the IIS version 5.1:

Go to your Internet Information Services (IIS) page (Go Start -> Settings -> Control Panel -> Administrative tools -> Internet Information services)

Unfold Websites->Default Web site

Now right click on your website name (on which you are executing your script)

Select Properties

Select the tab Virtual Directory

In that page, select the option High (Isolated) under Application Protection, this option will remove the default timeout settings.

Now click on the button Configuration

Then select Process Options tab

Change the CGI Script Timeout value max value is 999999.

That’s it. You may now run your script without any issue.

TAGS: ,

Local Host in Mozilla or Netscape browsers

Most of the users who are using local host in IIS are known to work only in Internet Explorer (IE) browser.

However, you may also browse your Localhost in both the Mozilla and in Netscape Browsers also. To browse your localhost in Mozilla and Netscape browsers just follow the simple steps provided below:

1) Type about:config in your address bar
2) In Mozilla it will prompt an alert message click the button “I’ll be careful, I promise”
3) Now in the filter box search for “network.automatic-ntlm-auth.trusted-uris
4) Double click on the Preference Name.
5) Enter the value “localhost” and click OK.
6) That’s it.. Your browser is now configured to use localhost.

Hope this is so helpful for many users.

TAGS:

Yahoo! India Local (beta)

Yahoo India has recently launched Yahoo! India Local (beta), a new local information destination. This new launch provides a convincing user experience with appropriate local information that blows the users daily needs. This Yahoo! India Local is presently available only across Delhi, Chennai, Mumbai and Bangalore.

Yahoo! India Local gives you relevant local information like Business listings, Maps, Directions, Local events, and Current movies. Users may also get listings from a wide range of categories such as restaurants, pubs, shopping malls, hospitals, schools, tailors, banks, health and fitness, and 24 hour pharmacies. This Yahoo! India Local is available at local.yahoo.in.

Users can write their own reviews, and also they leave footprints, mark businesses on the map, and add listings or events on Yahoo! India Local. Contributions shared by the community provide users with real insights into their experiences, thereby making them better informed. Local businesses across categories can now get listed for free on Yahoo! India Local. When users search for those categories, the businesses can get discovered.

Gopal Krishna, Head of Audience-Yahoo! India, said that: “Yahoo! India Local (Beta) exemplifies our strategy to be the leading starting point on the web, by providing the most relevant and compelling experience for local needs. He added that, “With this innovative product, we are trying to make the web more useful, engaging, and interesting and localized to our users”.

TAGS:

Fixing bugs in CSS

A high-quality web designer has to undergo every time he or she codes a page using CSS for design. Web Standards is the only way to go and it must be an obvious option when you take your job serious.

Confirm your markup is well structured

Make sure your markup is finely ordered, in other words make use of the suitable markup for the appropriate content. Apply headings for titles, paragraphs for blocks of text, ordered and unordered lists to sum things up in list form or for your navigation, field sets in combination with legend and label elements for forms… Finally, use tables only for what they are used for, tabular data.

Validate your markup

It’s not pretty much the green check mark in the bottom right hand corner of your browser or 0 errors or warning on the W3C Validator that matters. This is only an additional check and a confirmation that your code validates. The W3C markup validator or W3C CSS validator should be your tools to make your page an error free. Tools that facilitate you to create the right coding, but consider that this is just a machine that runs a test for you. Some coding faults, for instance using the incorrect or structure-less code for certain content will not be seen as an error by this machine, so make sure this is in order. Validate the pages is an absolute necessity before you begin to fix any CSS layout problems.

TAGS:

Steps to clear the Dreamweaver’s Start up Error

Most of the Macromedia’s Dreamweaver user may face the “dwscripts is not defined” in the startup. This may cause when the user may not shut it properly when he used Dreamweaver previously. To clear this error from the startup is so easy, simply follow the steps provided below.

1) First make sure you have closed your Dreamweaver application.
2) Now go to the following path in your computer respectively
C:\Documents and Settings\Administrator\Application Data\Macromedia\Dreamweaver 8\Configuration
3) In the ‘Configuration’ folder delete the file WinFileCache*.dat.
4) Now restart your DreamWeaver application

You may now open your Dreamweaver application without any issues.

Please note that the “Application Data” folder is hidden by default, so you have to change your Windows Explorer Folder Options setting to view all hidden folders.

TAGS:

About curl

cURL is the name of the project. The name is a play on ‘Client for URLs’, originally with URL spelled in uppercase, it obvious it deals with URLs. The fact it can also be called ‘see URL’ also helped, it works as an abbreviation for “Client URL Request Library” or why not the recursive version: “Curl URL Request Library”.

The cURL project produces two products:

libcurl

A free and easy to use the Client-side URL transfer library, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE and LDAP. Libcurl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunneling and more!

libcurl is highly portable, it builds and works identically on numerous platforms, including DOS ,Solaris, NetBSD, FreeBSD, OpenBSD, Darwin, AIX, HPUX, IRIX, Tru64, Linux, UnixWare, HURD, Windows, Amiga, OS/2, BeOs, Mac OS X, Ultrix, QNX, OpenVMS, RISC OS, Novell NetWare and more.

libcurl is free, thread-safe, IPv6 compatible, feature rich, well supported and fast.

curl

curl is a command line tool for getting or sending files using URL syntax.

Since curl uses libcurl, it supports a range of common Internet protocols, currently including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, LDAP, DICT, TELNET and FILE.

We pronounce curl and cURL with an initial k sound: [kurl].

Test with the following PHP code:

[php]
$url = "http://www.searchenginegenie.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$returned = curl_exec($ch);
curl_close ($ch);
echo $returned;
[/php]

TAGS:

To keep your PC’s Cool..

Normally during summer our PC components run themselves much hot abnormally. These computer components were not designed in such a way to work above a certain temperature.

So for a trouble-free computing, please follow the steps provided below to make sure that your PC stays cool.

1) Computer fans are one of most important component in PC’s, without them computer’s processor, hard disk and other very important parts may scorch and in due course fail or may slow down your computer speed or to working intermittently.

a. So once a year or especially beginning of summer is the right time to inspect the all the PC fans(i.e. processor fans, external fans) to ensure that they are working properly or not.

b. Clean the fans regularly as all the fans collect dust and function less efficiently as a result.

2) The Term ‘Overclocking’ is the used to attempts to run your computer parts at higher voltages or speeds than they were designed to support. You may configure the basic input output system (BIOS) by pressing DEL or F2 buttons when your computer boots up. But make sure unless you know what you’re doing and have taken steps specifically to provide extra cooling to your computer, avoid the attraction of Overclocking. If your cooling fails, your components will overheat much faster than otherwise – and may even be damaged permanently.

3) The next main thing is where you are placing your computer, when it comes to keeping your computer cool. It’s better to place your computers on the floor, if possible, since its cooler down there – and move them close to an air conditioning vent, too, if one is available. Do not place them close to other heat-generating devices.

4) One of the next most important computer components is Monitor; it generates a lot of heat when turned on – even when they’re not displaying an image. Get into the habit of turning off your monitor when you step away from the computer for extended periods of time.

You may also install and use few computer software programs which allow you to monitor your pc’s temperature. These utilities will prompt you when your computer components gets too hot.

TAGS: ,

Request a Free SEO Quote