trouble executing SP, SqlDbType.Bit...

Discussion in 'ASP .Net' started by Jeff, Apr 16, 2007.

  1. Jeff

    Jeff Guest

    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
    Jeff, Apr 16, 2007
    #1
    1. Advertising

  2. It 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:

    > 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
    >
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Apr 16, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerome

    Name 'SqlDbType' is not declared?

    Jerome, Apr 27, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    1,525
    Jerome
    Apr 27, 2004
  2. Replies:
    2
    Views:
    2,774
    William F. Robertson, Jr.
    May 26, 2004
  3. Patrick Olurotimi Ige

    SqlParameters SqlDbType.Char in VB Question

    Patrick Olurotimi Ige, Jun 11, 2005, in forum: ASP .Net
    Replies:
    10
    Views:
    1,076
    Teemu Keiski
    Jun 22, 2005
  4. Kevin R
    Replies:
    6
    Views:
    5,367
    sumitha.v.r
    May 19, 2011
  5. =?Utf-8?B?RGFiYmxlcg==?=

    SqlDbType sizes

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    1,819
    Christopher Reed
    Mar 29, 2006
Loading...

Share This Page