[Mono-list] SQL Query Difference between ASP.NET and Mono
willisterman
craig.willis at myknowledgemap.com
Fri Jan 30 06:45:57 EST 2009
I've compiled from the SVN code, which had that your patch applied in
Revision 124963, and can confirm that the SQL now works as expected, I no
longer recieve the error message, and the generated SQL is not missing the
required '@'.
Thanks for that!
Veerapuram Varadhan wrote:
>
> 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
>> >
>>
>
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>
--
View this message in context: http://www.nabble.com/SQL-Query-Difference-between-ASP.NET-and-Mono-tp21709297p21745749.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list