문제

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?

도움이 되었습니까?

해결책

... 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top