[Mono-list] SQL Query Difference between ASP.NET and Mono

Veerapuram Varadhan vvaradhan at novell.com
Thu Jan 29 10:55:05 EST 2009


Hi,

Can you try the fix attached to
https://bugzilla.novell.com/show_bug.cgi?id=470579 ?

Thanks for the report.

V. Varadhan

On Thu, 2009-01-29 at 01:52 -0800, willisterman wrote:
> I've been doing a bit more testing on this, and it happens both with a
> windows install of XSP, and the Mono 2.2 VMWare image, both cause that code
> to error with "cannot use output when passing a constant to a stored
> procedure"
> 
> 
> willisterman wrote:
> > 
> > Afternoon everyone,
> >   I've been in the process of converting a project to run on Mono, from
> > pure ASP.NET, and I've noticed that a perticular group of SQL Querys dont
> > work, returning the error: "cannot use output when passing a constant to a
> > stored procedure"  This perticular code works fine on ASP.NET:
> > 
> > SqlCommand command = new SqlCommand(@"
> > INSERT INTO tbl_Workpad
> > (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;
> > 
> > 			Comp.Data.SqlDB.ExecuteNonQuery(command);
> > 
> > 			int newId = int.Parse(command.Parameters["@NewId"].Value.ToString());
> > 
> > 		        Workpad workpad = new Workpad(newId, name, lastEditedOn, type,
> > true);
> > 
> > 			return workpad;
> > 
> > ON ASP.NET, the SQL created from this is as follows:
> > 
> > declare @p3 int
> > set @p3=932
> > exec sp_executesql N'
> > INSERT INTO tbl_Workpad
> > (name, userId, type, lastEditedOn)
> > VALUES
> > (@Name, @UserId, @Type, @LastEditedOn)
> > 
> > SET @NewId = @@IDENTITY
> > 			',N'@NewId int output, @UserId uniqueidentifier, @Name nvarchar(256),
> > @LastEditedOn datetime, @Type nvarchar(256)',  @NewId=@p3 output,
> > @UserId='3', at Name=N'df43frsdfsdf', at LastEditedOn='2009-01-28
> > 16:02:30:760', at Type=N'simple'
> > select @p3
> > 
> > But on Mono you get:
> > 
> > declare @NewId int
> > set @NewId=NULL
> > exec sp_executesql N'
> > INSERT INTO tbl_Workpad
> > (name, userId, type, lastEditedOn)
> > VALUES
> > (@Name, @UserId, @Type, @LastEditedOn)
> > 
> > SET @NewId = @@IDENTITY
> > 			',N'@NewId int output, @UserId uniqueidentifier, @Name nvarchar(256),
> > @LastEditedOn datetime, @Type nvarchar(256)',  @NewId=NewId output,
> > @UserId='3', @Name=N'xzczxc', @LastEditedOn='Jan 28 2009 03:04:02.321 PM',
> > @Type=N'simple'
> > select @NewId
> > 
> > The only difference between them is: 
> > 
> > ASP.NET: @NewId=@p3 output
> > MONO: @NewId=NewId output
> > 
> > For some reason, the @ is getting missed out.  If I manually add it to the
> > query, it runs fine.
> > 
> > Is this a bug with mono, or is there something I can do to fix this?
> > 
> > Thanks for any help.
> > 
> > Craig
> > 
> 



More information about the Mono-list mailing list