Question

I've seen this question asked here before, but never when Enterprise Library is used. I've used code like the following before and it works fine. What's the problem this time? I get the error on the last line:

    Database db = new SqlDatabase(MyConfiguration.Current.ConnectionString);
    DbCommand cmd = db.GetStoredProcCommand("AddWorkListItem");

    db.AddInParameter(cmd, "@PartNumber", DbType.String, partNumber);
    db.AddInParameter(cmd, "@Quantity", DbType.Int32, qty);
    db.AddInParameter(cmd, "@WorkListTypeCode", DbType.String, code);
    db.AddInParameter(cmd, "@UserKey", DbType.Int32, userKey);

    return cmd.ExecuteNonQuery();
Was it helpful?

Solution

Gosh it's been a while but I'm pretty sure you call db.ExecuteNonQuery(cmd) rather than cmd.ExecuteNonQuery(). Have you tried that?

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