locked
bool true, false values with SqlData RRS feed

  • Question

  • If i have a bit type in my SQLDB called IsNew....which holds 0 or 1...can i use as something like When i have a new customer i can Insert data that will enter a value of 1 in the IsNew column....so if i had a property in my code called _IsNew that i set it to the value of IsNew in my database....could i do something like??? could that work like so....I am trying to get a better understanding of using bool flags in data driven applications???

    if(_IsNew)

    {

    insert data

    }

    else

    {

    update data

    }

     

     

    Wednesday, August 30, 2006 8:59 PM

Answers

  • Yes, you could pass boolean value to the parameter of the SQL statement and it will convert it into the bit value automatically
    Thursday, August 31, 2006 1:15 AM

All replies

  • Yes, you could pass boolean value to the parameter of the SQL statement and it will convert it into the bit value automatically
    Thursday, August 31, 2006 1:15 AM
  • Just a thought.

    If you are actually considering this with a record, then the better way to do is to record the create date, and then with queries on the customer use SQL Date Functions to return a boolean to your output. 

    Eg. Test the create date value to see if the date is earlier than one weeks from now, return a negative, else return a true.

    Ref - DATEDIFF()

    http://msdn2.microsoft.com/en-us/library/ms139927.aspx

     

    Thursday, August 31, 2006 2:26 AM