[Mono-bugs] [Bug 470579] New: SqlCommand.ExecuteNonQuery throws exception when trying to execute commands that returns values in output parameter

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Jan 29 06:42:22 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=470579


           Summary: SqlCommand.ExecuteNonQuery throws exception when
                    trying to execute commands that returns values in
                    output parameter
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.2.x
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Data.SqlClient
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: vvaradhan at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User


Execute the following piece of code:

SqlCommand command = new SqlCommand(@"
INSERT INTO tbl_test
(name, userId, type, lastEditedOn)
VALUES
(@Name, @UserId, @Type, @LastEditedOn)

SET @NewId = @@IDENTITY
                        ");
                        command.Parameters.Add("@NewId", SqlDbType.Int);
                        command.Parameters["@NewId"].Direction =
ParameterDirection.Output;
                        command.Parameters.Add("@UserId",
SqlDbType.UniqueIdentifier).Value =
userId;
                        command.Parameters.Add("@Name", SqlDbType.NVarChar,
256).Value = name;
            command.Parameters.Add("@LastEditedOn",
SqlDbType.DateTime).Value = lastEditedOn;
            command.Parameters.Add("@Type", SqlDbType.NVarChar, 256).Value =
type;

                        SqlDB.ExecuteNonQuery(command);

                        int newId =
int.Parse(command.Parameters["@NewId"].Value.ToString());

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list