Question

I've got this code:

using (SqlCeConnection sqlConn = new SqlCeConnection(@"Data Source=\my documents\\PlatypusDB.SDF"))
{
    sqlConn.Open();
    string dmlStr = "insert into platypus_settings (setting_name, setting_value) values(?, ?)";
    SqlCeCommand cmd = new SqlCeCommand(dmlStr, sqlConn);
    cmd.CommandType = CommandType.Text; //<-- necessary?
    cmd.Parameters[0].Value = settingName;
    cmd.Parameters[1].Value = settingVal;
    try
    {
        cmd.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        Platypus.ExceptionHandler(ex, "writeSettingsVal");
    }
}

...but don't know if the commented line is needed, is bloatcode, or doesn't matter either way?

Was it helpful?

Solution

... but don't know if the commented line is needed

No. Not because it's obvious but because it happens to be the default.

From MSDN:

Property Value
One of the CommandType values. The default is Text.

Having said that, it certainly is not bloat-code and I might include it, just to make the code a little less ambigious to read.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top