More .NET gotchas

I ran into a couple more little "gotchas" in my .NET adventures this afternoon.

First, an ADO.NET gotcha. In my ignorance, while writing a parameterized insert query for a DataAdapter, I assumed that if a certain database field was automatically generated, such as an auto-number primary key, that I didn't need to specify it in the insert query. However, it doesn't work that way. When omitting those fields, on calling the DataAdapter.Update() method, I got a nice error saying I didn't supply enough fields, or something like that (I didn't write it down). Of course, this could be provider-specific (I was using the Jet 4.0 OLEDB provider), but I didn't feel like experimenting with it at the time.

The other gotcha was with the Combobox.AutoCompleteMode property. I had a combobox with AutoCompleteMode set to SuggestAppend with the source set to the drop-down list contents. I couldn't figure out why, for one of the entries, the appended text was cutting off half way through the string. It turns out that this was because the string in question had a slash in it. According to the documentation, "automatic completion appends all characters only up to and including the slash." I'm not sure why, though.

You can reply to this entry by leaving a comment below. You can send TrackBack pings to this URL. This entry accepts Pingbacks from other blogs. You can follow comments on this entry by subscribing to the RSS feed.

Add your comments #

A comment body is required. No HTML code allowed. URLs starting with http:// or ftp:// will be automatically converted to hyperlinks.