Monday, March 26, 2012

trouble executing SP, SqlDbType.Bit...

ASP.NET 2.0

This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this?? I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong

This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessage @dotnet.itags.org.id uniqueidentifier, @dotnet.itags.org.user int, @dotnet.itags.org.type
bit

Here is the ASP.NET code
public override void DeleteMessage(System.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("SendMessage", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@dotnet.itags.org.id", SqlDbType.UniqueIdentifier).Value = id;
cmd.Parameters.Add("@dotnet.itags.org.user", SqlDbType.Int).Value = user;
cmd.Parameters.Add("@dotnet.itags.org.type", SqlDbType.Bit).Value = type;
}
}

any suggetions?

JeffIt says boolean, so you need to pass true (with no quotation marks) or false
-- for the value.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

Quote:

Originally Posted by

ASP.NET 2.0
>
This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this?? I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong
>
This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessage @.id uniqueidentifier, @.user int, @.type
bit
>
Here is the ASP.NET code
public override void DeleteMessage(System.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("SendMessage", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@.id", SqlDbType.UniqueIdentifier).Value = id;
cmd.Parameters.Add("@.user", SqlDbType.Int).Value = user;
cmd.Parameters.Add("@.type", SqlDbType.Bit).Value = type;
}
}
>
any suggetions?
>
Jeff
>
>
>

0 comments:

Post a Comment