Overload ExecuteNonQuery() for query with Parameterlist

Topics: Data Access Application Block
Apr 17, 2008 at 8:43 AM
Hi, I am new in Enterprise Library and this discussions also. I have a Insert satement which is inline and a parameter list. but in ExecuteNonQuery() there is nothing to do query with parameter list, How can I overload ExecuteNonQuery() to do this. If anyone have this or have idea, please help me out with sample code..

Apr 17, 2008 at 9:52 AM
You should add you parameters manual to the cmd object.

Apr 17, 2008 at 2:45 PM
private void ExecuteStoredProcedure(LogEntry logEntry) {
	using (DbConnection connection = database.CreateConnection()) {
		try {
			using (DbTransaction transaction = connection.BeginTransaction()) {
				try {
					ExecuteAddCategoryStoredProcedure(logEntry, logID, database, transaction);
				catch {
		finally {
private void ExecuteAddCategoryStoredProcedure(LogEntry logEntry, int logID, Data.Database db, DbTransaction transaction)
	foreach (string category in logEntry.Categories) {
		DbCommand cmd = db.GetStoredProcCommand(addCategoryStoredProcName);
		db.AddInParameter(cmd, "categoryName", DbType.String, category);
		db.AddInParameter(cmd, "logID", DbType.Int32, logID);
		db.ExecuteNonQuery(cmd, transaction);