You are here

Blogs

The ROI Lowdown on Virtualization 2009

I am going to get together with one of the smart guys from Seismic, Craig Cook, live on May 21st to give the ultimate lowdown on server Virtualization.  And wonder of wonders, we'll be done in 45 minutes, how can you beat that!  Oh yeah, and it's free.

Current ASPX Page Name

Get the name of the current ASP.NET page.

string path = System.Web.HttpContext.Current.Request.Url.AbsolutePath; string name = System.IO.Path.GetFileName( path );

About the Author:

Handling Multiple Events With A Delegate

In a recent multi-tab VB.NET Web application, the values from a 3 controls on a tab (tab A) were used as filters for a dropdownlist on a subsequent tab (tab B).  If the controls on tab A were changed, the dropdownlist on tab B would be reloaded based on the changed value(s). 

SqlConnectionStringBuilder

Occasionally there's a need to construct a new connection string from user input instead of using a predefined one from the Web.Config file.  Using the SqlConnectionStringBuilder class, a new connection string can be constructed easily without resorting to string concatenations. private string BuildConnectionString() {     SqlConn

Injecting JavaScript from an Ajax Update Panel

I started using the Update Panel control recently to verify that an email address entered on a registration form was not a duplicate.  If the email address as a duplicate, I wanted to display a simply JavaScript alert to notify the user without resorting to hidden fields.  After much searching  I found the The

Remove Duplicate Records

The following is one approach to removing duplicate records from a table assuming the first entry is the one to keep.

DELETE  c1

FROM    dbo.contact c1

            INNER JOIN( SELECT  emailaddress, MIN(contactid) AS contactid

                        FROM    dbo.contact

                        GROUP   BY emailaddress

                        HAVING  COUNT(*) > 1

            ) c2 ON c1.emailaddress = c2.emailaddress

WHERE   c1.contactid > c2.contactid

About the Author:

DbProviderFactory GetConnection

With the new ADO.NET 2.0 DbProviderFactory and DbProviderFactories classes, you can change the database provider at runtime.  The DbProviderFactories class is use to create a factory object, which in turn is use to create the appropriate provider objects (connection, command, dataadapter, etc).  Here's an example that returns a DbConnection object based on the name of the connection string in the Web.config file.

/// <summary>

/// Create generic database connection object using new DbProviderFactories class.

Table Column To CSV

The following query converts a column of data in a SQL table to a comma-delimited string. This works great for tables with a few hundred rows and limited to the size of the VARCHAR data type. A TEXT field can also be use if needed for large tables, but requires a little more work.

Pages