I\'ve been using cmd.Parameters.AddWithValue, and not specifying a DBType (int, varchar,...) to run queries. After looking at SQL Profiler, it seems that queries run with t
I just ran into this EXACT problem. I've got a legacy database with a lot of char columns. Without specifying the type of column the results took a couple of minutes on one of my queries. (It default to nvarchar.) Specifying the column type caused the results to take seconds.
cmd.Parameters.AddWithValue("charcolumn", "stringvalue");
cmd.Parameters[0].SqlDbType = SqlDbType.Char;
I think I'm going to try having every string query as a char type and see how that goes.
[edit]
Actually... after reading this: http://www.u2u.info/Blogs/U2U/Lists/Posts/Post.aspx?ID=11
I've decided to go with this solution:
cmd.Parameters.AddWithValue(colName, val);
if(val is string)
cmd.Parameters[i].DbType = DbType.AnsiString;