title: Not sure why in c# I get a totally different TypeCode from a DbType within a SQL command parameter object?
body: <p>I am sure someone is going to shoot this one down in flames.. although the concept from what I can see looks ok...</p>
  
  <p>Basically I am trying to dynamically set a SQL command paramter type and value.  So basically I am:</p>
  
  <ol>
  <li>Getting the DbType of the parameter dynamically.. so that part is fine - just referencing like: DbType ParamDBtype = cmd.Parameters[Param1Variable.DbType;</li>
  <li>Then (stupidly or not!) I am trying to get the Type for within .NET so I can convert value to the correct type (because in my case I am just getting value/pairs as strings.. hence the reason for getting the DbType to <em>know</em> what type to convert to)</li>
  </ol>
  
  <p><em>So apparently I can do:</em>
  TypeCode ParamDBtypeCode = cmd.Parameters[Param1Variable.DbType.GetTypeCode();</p>
  
  <p>Now the TypeCode can be used when using the Convert statement:</p>
  
  <p>Convert.ChangeType(Param1Value, ParamDBtypeCode)</p>
  
  <p>Well it works.. sort of, because I had a param that was an integer, and the conversion converted that value to an int.. but then I had a param which was an AnsiString DbType, and the TypeCode of that param came back as int16 still???</p>
  
  <p>Anyone had this type of issue, or can point me in a better direction?</p>
  
  <p>Essentially I am trying to assign/convert values to the stored procedure dynamically..</p>
  
  <p>Thanks for any help..</p>