Rob Kraft's Software Development Blog

Software Development Insights

Archive for December, 2008

How to create a Password column using the DataGridView

Posted by robkraft on December 19, 2008

If you want to hide the password value in a Visual Studio DataGridView control, you can use the code below.  If a user clicks into the cell to edit the value, then the current value becomes visible.
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
    if (
dataGridView1.Columns[e.ColumnIndex].Name == “passwordDataGridViewTextBoxColumn” && e.Value != null)
    {
       
dataGridView1.Rows[e.RowIndex].Tag = e.Value;
        e.Value = new String(
‘*’, e.Value.ToString().Length);
    }
}

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
    if (
dataGridView1.CurrentRow.Tag != null)
        e.Control.Text =
dataGridView1.CurrentRow.Tag.ToString();
}

I found the example above on this web page, in a non-english language:

Posted in Visual Studio 2005, Visual Studio 2008 | Tagged: , | 3 Comments »

December issue of ASP.NetPro

Posted by robkraft on December 12, 2008

 The December issue of ASP.NetPro is available online at: http://www.aspnetpro.com/PDF/Issues/aspDEC2008.pdf.  The issue contains an article on Migrating from VB6, an article on developing an inline edit control, and several other good articles.

Posted in Magazine Online | Leave a Comment »

Negative Process ID (spid -2) in SQL Server

Posted by robkraft on December 12, 2008

I didn’t know negative spids existed until I found one blocking other processes on my SQL Server 2005 box.  The source of the negative spid (SQL Server Process ID), specifically a spid of -2, was the Microsoft Distributed Transaction Coordinator (MSDTC).  Most applications probably never go through MSDTC, but if you want your application to modify tables in multiple databases as a single transaction, then MSDTC is the developer’s friend because it makes the transaction easy to code.  The trade-off is that a little bit of transaction management resides outside of SQL Server in the MSDTC.  If the application fails to commit or rollback the transaction, the MSDTC transaction becomes orphaned and is assigned a spid -2.

Getting rid of this database connection is not as easy as issuing a kill for spid -2, but you just need to perform one additional step.   To kill the orphaned transaction:

1) Use this query to get the UOW (a GUID) of the offending transaction:

use master

select distinct req_transactionUOW from syslockinfo

 

Note:  Ignore the UOW records that are all zeros. “00000000-0000-0000-0000-000000000000”

2) Use the Kill command, replacing the GUID below with the req_transactionUOW obtained from the query above, to kill the offending transaction:

KILL 'D5499C66-E398-45CA-BF7E-DC9C194B48CF'
 
Repeat for each orphaned transaction.
 
You can find more about killing transactions at http://technet.microsoft.com/en-us/library/ms173730.aspx.

Posted in SQL Server | Tagged: | 1 Comment »

Is StackOverflow.com the last newsgroup we will ever need?

Posted by robkraft on December 12, 2008

I’m very impressed by www.StackOverflow.com.  The site is similar to a newsgroup and accepts posts on all things related to software development.  However, unlike traditional newsgroups that are segragated by topic, StackOverflow uses tags for each post.  This allows a single post to be grouped into multiple topics; which is more convenient for posters than posting the same topic in several traditional newsgroups.

But the benefits don’t stop with the tags.  StackOverflow.com also provides a rating and feedback system.  All users can judge the answers and your contributions count toward your overall site score.  I’ll bet this makes the site a little more fun and encourages use in order to increase your total score.

Posted in Online Resources | Tagged: | Leave a Comment »

Weekly e-mail from ASPAlliance.com

Posted by robkraft on December 9, 2008

I receive an email about once per week from ASPAlliance.com.  The e-mail has often contained links to good articles that help me solve the challenges I face developing with ASP.Net.  The e-mail is free, of course, if you create an account on their site.

Posted in Informative Emails | Tagged: , | Leave a Comment »

Daily e-mail from CodeProject.com

Posted by robkraft on December 4, 2008

One of my favorite regular e-mails is the daily e-mail I receive from CodeProject.com.  Their “Industry Insider” helps keep me aware of new product releases and industry happenings relevant to software developers.  The e-mail is free, of course, if you create an account on their site.

Posted in Informative Emails | Tagged: , | Leave a Comment »

The December issue of Better Software magazine is now available

Posted by robkraft on December 3, 2008

The December issue of Better Software magazine is now available online at http://www.nxtbook.com/nxtbooks/sqe/bettersoftware1208/

The cover article is “What’s a Manager To Do?”, and there are several good articles in this issue, as always.

Posted in Magazine Online | Tagged: | Leave a Comment »

November issue of ASP.Net Pro Magazine available as PDF

Posted by robkraft on December 3, 2008

The November issue of asp.netPro magazine is available as PDF at http://www.aspnetpro.com/PDF/Issues/aspNOV2008.pdf

The Featured Article is “Data Application Tricks”.  There are many other good articles too!

Posted in Magazine Online | Tagged: | Leave a Comment »