Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to know/check whether a value is SqlDbType compatible or not?
    text
    copied!<p>I'm assigning objects to this list of SqlParameter and then trying to execute the SqlCommand, but it throws an exception saying that one of the objects could not be converted into SqlDbType. Preferably I want to handle such objects before adding them to the parameter collection list. So, how would I check whether a value being added to parameter list is a good/proper one or not? What property should I check for?</p> <p>Here's is my code : </p> <pre><code>bool Submit(Progs progs, CommandType commandType, string commandText) { try { List&lt;SqlParameter&gt; paramCollection = new List&lt;SqlParameter&gt;(); foreach(Prog p in progs) { SqlParameter spTemp = new SqlParameter { ParameterName = p.Name , Value = p.Value}; paramCollection.Add(spTemp); using (SqlConnection con = GetConnection()) { SqlCommand cmd = new SqlCommand { CommandType = commandType, CommandText = commandText, Connection = con }; con.Open(); cmd.Parameters.AddRange(paramCollection ); // Exception is thrown from this line cmd.ExecuteNonQuery(); } return true; } catch(Exception exc) { return false; } } </code></pre> <p>The exception thown says : <strong>No mapping exists from object type sol2.CodeBase.BL.Letter[] to a known managed provider native type.</strong></p> <p>PS : There is a property for of SqlParameter called <strong>ParamaterIsSqlType</strong>(yes, it's paramAter and not paramEter), which appears only during runtime(i.e. when I inspect spTemp with a breakpoint on the next line) and which is always set to false? What kind of property is this, so that it appears only during runtime??? Also, what value this "ParamaterIsSqlType" indicates?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload