Archive for the 'All' Category
DELETE button not captured by KeyPress event
June 17th, 2010A small but important thing – if you want to capture pressing the DELETE button in a WinForms project, you’ll need to do it in the KeyDown or KeyUp event, not the KeyPress event. As the documentation (here and here) points out, KeyPress deals mostly with character keys, and non-character keys won’t raise it.
Remove items from Visual Studio Recent Projects list
May 19th, 2010Here are a couple handy links describing how to remove items from the Recent Projects list on the Visual Studio start page. Basically, in versions prior to VS2010, it’s a registry hack (I’ve read that VS2010 provides a way to do this within the IDE, but I haven’t played with 2010 yet so I can’t [...]
Working with winmm.dll to play audio files in .NET
April 29th, 2010I’m working on a little utility application that will transfer audio files from a recorder to a computer drive. Part of the functionality is to display the audio files, and let users listen to a little snippet of the audio file if they so desire. A quick google search led me to this page containing [...]
DataGridViewComboBox Column Properties
April 26th, 2010I am copying this verbatim from a post I found by Kevin Spencer which is the clearest explanation I have seen of the main properties of a DataGridViewComboBox. It’s here for my reference. Yay if it helps you too!
The DataGridView itself has a DataSource property that determines what columns are in it. The [...]
System.Data.OleDb.OleDbException: Unspecified error
March 17th, 2010I ran across this error in an ASP.NET project that was using ADO.NET to access the data in a .csv file (more info here). After much gnashing of teeth, I finally ran across this blog post, that explained the problem and provided a link to this MSDN article.
Basically, you need to make sure that the [...]
Use HttpModule to turn tracing on via the querystring
May 18th, 2009Sometimes I want to turn tracing on in a production application to troubleshoot issues that I can’t replicate on my development machine. It’s easy enough to do this by turning on application-level tracing in the web.config file, like so:
<configuration>
<system.web>
<trace enabled=”true” pageOutput=”true” />
</system.web>
</configuration>
The problem with this is that changes to the web.config file cause the app domain to [...]
Ordinal Numbers in T-SQL
February 27th, 2009I wanted to write a query that took numbers and turned them into ordinal numbers – re: 1 = 1st, 2 = 2nd, 3 = 3rd, etc.
I took this code from Chip Pearson’s web site. His posting was about ordinal numbers in Excel. I converted the code to a T-SQL function, and I can now [...]
Using “Execute As” to Test a Stored Procedure as a Different User
February 19th, 2009In an earlier blog post, I wrote about how to use “Execute As” in a stored procedure to access a separate database. When you include “Execute As” in a stored procedure, you can pull data from a separate database without giving your users direct permissions on that database.
Another way I really like to use “Execute [...]
Find First Day of Month, Last Day of Month, etc
November 26th, 2008Today I was writing some code where I needed to calculate the end of the month for a certain date. As per usual, I Googled, and found various examples, some using old VB functions, some using methods of the Date object, some very involved and using lots of string manipulation and converting of things from [...]
How to connect to a SQL Server Named Instance
August 21st, 2008This is something I just don’t remember, so I thought this would be a good place to post it. If you are trying to connect to a named instance of SQL Server, for example TECHKNOWSOLVE\TECHKNOWSOLVE2000, you might get an error in your code that says this server doesn’t exist. The quick and easy [...]