Programmatically using SqlDataSource

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Jun 11, 2007.

  1. hey all,

    i have the following statement:

    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {

    SqlDataSource1.UpdateParameters["FollowUp"].DefaultValue=((CheckBox)sender).Checked?"1":"0";
    SqlDataSource1.Update();
    }

    Regarding what i assigned the parameter's default value: the "FollowUp"
    field in the database is a bit. I noticed if I used .Checked?true:false it
    didin't work because you can't convert bool to string. But i thought it was a
    bool in the database?

    just needing some help in understanding.

    thanks,
    rodchar
    =?Utf-8?B?cm9kY2hhcg==?=, Jun 11, 2007
    #1
    1. Advertising

  2. On Jun 11, 10:17 pm, rodchar <>
    wrote:
    > hey all,
    >
    > i have the following statement:
    >
    > protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    > {
    >
    > SqlDataSource1.UpdateParameters["FollowUp"].DefaultValue=((CheckBox)sender)­.Checked?"1":"0";
    > SqlDataSource1.Update();
    > }
    >
    > Regarding what i assigned the parameter's default value: the "FollowUp"
    > field in the database is a bit. I noticed if I used .Checked?true:false it
    > didin't work because you can't convert bool to string. But i thought it was a
    > bool in the database?


    Bit is an integer data type and can be used to store 0, 1, or NULL.
    Alexey Smirnov, Jun 11, 2007
    #2
    1. Advertising

  3. but when you go into management studio you put a true or false right?

    "Alexey Smirnov" wrote:

    > On Jun 11, 10:17 pm, rodchar <>
    > wrote:
    > > hey all,
    > >
    > > i have the following statement:
    > >
    > > protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    > > {
    > >
    > > SqlDataSource1.UpdateParameters["FollowUp"].DefaultValue=((CheckBox)sender)-.Checked?"1":"0";
    > > SqlDataSource1.Update();
    > > }
    > >
    > > Regarding what i assigned the parameter's default value: the "FollowUp"
    > > field in the database is a bit. I noticed if I used .Checked?true:false it
    > > didin't work because you can't convert bool to string. But i thought it was a
    > > bool in the database?

    >
    > Bit is an integer data type and can be used to store 0, 1, or NULL.
    >
    >
    =?Utf-8?B?cm9kY2hhcg==?=, Jun 12, 2007
    #3
  4. On Jun 12, 3:16 pm, rodchar <> wrote:
    > but when you go into management studio you put a true or false right?
    >


    Right, and I don't know why they decided to convert sql-bit to ".Net
    Framework Data Type: Boolean" in a table browser of the management
    studio.

    I think many people are confused over the difference between True/
    False and 1/0

    Anyhow, use 0, or 1 to define a bit value (in this case it will be
    compatible with SQL 2000).
    Or use 'True', or 'False' (in apostrophes)
    Alexey Smirnov, Jun 12, 2007
    #4
    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. Replies:
    1
    Views:
    7,409
    Markus
    Aug 25, 2005
  2. Vili
    Replies:
    1
    Views:
    454
  3. dcship
    Replies:
    3
    Views:
    1,173
    Mark Rae [MVP]
    May 5, 2010
  4. dcship
    Replies:
    0
    Views:
    744
    dcship
    May 4, 2010
  5. MitchW
    Replies:
    1
    Views:
    163
    Mohamad Elarabi
    Dec 19, 2007
Loading...

Share This Page