[Mono-list] SQL Query Difference between ASP.NET and Mono
willisterman
craig.willis at myknowledgemap.com
Wed Jan 28 11:32:07 EST 2009
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
--
View this message in context: http://www.nabble.com/SQL-Query-Difference-between-ASP.NET-and-Mono-tp21709297p21709297.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list