[WinForm] How to dynamically add a drop down list in datagridview control

Scenario: You need to dynamically add a drop down list in a DataGridView control in a WinForm. Requirements: The items of the drop down list are dynamically bound with data from database. Solution: 1. Connect to database and retrieve data into a datatable, i.e. dtRanks; 2. Create a DataGridViewCombBoxColumn, set necessary properties of the CombBox column, then add it to the GridView control: DataGridViewComboBoxColumn ranks = new DataGridViewComboBoxColumn(); ranks.DataPropertyName = “TestID”; ranks.Name = “TestID”; ranks.HeaderText […]

MS SQL Server Express Error 5123 When Attaching a Database

I have been using MS SQL Server Management Studio Express to attach and detach my database for some time and have not had any problems until today. When I tried to attach a database, MS SQL Server Management Studio Express gave me error 5123: Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum) Additional Information: … CREATE FILE encountered operating system error 32(The process cannot access the file because it is being used by another process.) […]

MSDTC on server ‘\SQLEXPRESS’ is unavailable

I am currently working on a Windows application with C# and MS SQL Server 2005 Express as the back-end database. It’s been working fine until today when it gave me an error message when I tried to update a datatable. The error message is: MSDTC on server ‘(server name)\SQLEXPRESS’ is unavailable. According to Microsoft SQL Server 2005 Express Edition with Advanced Services Readme (see section 3.4), the cause of the error is: Because the Microsoft […]

Forms Authentication in ASP.NET 2.0 without Membership Provider

The membership provider is a new feature in ASP.NET 2.0 and helps web developers quickly and easily  implement forms authentication and authorization in their web applications. But what if you can’t use the membership provider in your applications? For example, my company implements a single sign-on system for authentication (many companies have the similar single sign-on system), and the user who is accessing our web application  is redirected to the single sign-on page for authentication. […]

A week of Ubuntu

I was very frantic with Ubuntu in the past week. Why? The reason is very simple: my laptop HP zu1175 is too old to handle Windows XP, but I do not want to throw it away, so I decided to give Linux a try. Here is my old HP zu1175 laptop’s specs: CPU: Pentium III 700MHz RAM: 384 MB HD: 20 GB DVD-ROM CDRW-ROM Pretty old, right? I used to think Fedora Core would be […]

SHUTDOWN is in progress. Login failed for user ‘…’. Only administrators may connect at this time.

Today, one of my web sites went down and the application sent me an exception error message like “SHUTDOWN is in progress. Login failed for user ‘…’. Only administrators may connect at this time.” It worried me at first because I thought my web site was under some malicious attack caused the server to shut down. So I searched the Internet with the error message and it turned out that it had nothing to do […]

ConstraintException occurred when updating DataTable with TableAdapter

I have been using SqlDataAdapter and strong typed DataSet and DataTable in my projects in .NET 1.1 for quite some time and have not had any problems. Now, in .NET 2.0, SqlDataAdapter is replaced with TableAdapter, which is much easier than SqlDataAdapter to create a data access layer. When I played with it in one of my projects last week, I came across an exception error when updating a DataTable with TableAdapter. The error happens […]

System.ArgumentOutOfRangeException occurs when updating DataView object

I have been working on a project which involves sending out emails to our customers in the past week and came across a very interesting error with a DataView object. The application is required to send out batch emails once a day, so I created an email message queue table to store the outgoing email messages. After a message is sent, the column that stores the delivery status will be changed from 0 to1 so […]

Keyboard Shortcut Reference Posters for Visual Studio

When I was searching the Internet for some keyboard shortcuts for Visual Studio 2005, I found that Microsoft already kindly created some FREE keyboard shortcut reference posters for VB, C#, and C++.  Here are the links: Visual Basic 2005 Keyboard Shortcut Reference Poster Visual C# 2005 Keyboard Shortcut Reference Poster Visual C++ 2005 Keyboard Shortcut Reference Poster These posters, however, only list the commonly used keyboard shortcuts for Visual Studio, and a complete list of […]

Fedora Core 8 released

Although I am a developer on Windows platform, mainly with .NET framework, I still try to keep up with what is happening in Linux community. Among all the major Linux distributions, Fedora Core is my favorite, and Ubuntu comes next. One of the reasons that I like Fedora Core is there are many developers supporting it by building many useful applications for this distribution. Another feature of FC that attracts me is that it makes […]