Exemple #1
0
        /// <summary>
        /// Executes an insert statement with multiple parameters.
        /// </summary>
        /// <returns>An int representing the number of rows effected.</returns>
        private static int ExecuteNonQuery()
        {
            var sql        = "INSERT INTO MyTable(Col1, Col2) VALUES(@val1, @val2)";
            var parameters = new IDbDataParameter[]
            {
                _DB.CreateParameter("@val1", ADONETType.VarChar, "My parameter"),
                _DB.CreateParameter("@val2", ADONETType.Int, 15)
            };
            int returnValue = 0;

            try
            {
                returnValue = _DB.ExecuteNonQuery(sql, CommandType.Text, parameters);
            }
            catch (Exception e)
            {
                // Exception handling code goes here...
            }
            return(returnValue);
        }