I have the following code:
Dim oPNParam As IDbDataParameter = oCmd.CreateParameter()
oPNParam.ParameterName = "@PartNumber"
oPNParam.DbType = DbType.String
oPNParam.Value = PartID
oCmd.Parameters.Add(oPNParam)
This code ends up executing sql side where the parameter type is Nchar(7). I checked out the documentation on MSDN and found a bit about how char isn't suported as the DbType, which I can confirm is not part of System.Data.DbType. My sql admins inform me that this statement executes poorly as a conversion of the partNumber field from the DB from char(7) to nchar(7) occurs, resulting in indexes not being utilized. He claims this is because of the type associated with the parameter I define in the code above.
The question here is how do I modify this code to explicitly tell the parameter it should be type char(7)? I found the StringFixedLength types and such but am really struggling to find any meaningful info on how to accomplish this.
One would think it'd be something like:
Dim oPNParam As IDbDataParameter = oCmd.CreateParameter()
oPNParam.ParameterName = "@PartNumber"
oPNParam.DbType = DbType.StringFixedLength
oPNParam.Size = 7
oPNParam.Value = PartID
oCmd.Parameters.Add(oPNParam)
But I'm looking for confirmation that this would, or a link to documentation which I seem unable to find.