Results 1 to 15 of 15

Thread: 2008 bit data type problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    123

    2008 bit data type problem

    I restored a backup from SQL 2000 to SQL 2008R2, now in 2000 the bit value was 0 and 1, but 2008 designates it true/false. The software i'm using for this (it was specially developed) is returning errors because of this.

    unfortunatly the original source code is no longer available so i cant make the changes at the source code level. Is there any way to set 2008 to use the old bit value, if not is there any alternatives you can recommend that will produce the same result using other data types. From what i can gather the application is loading items into combo boxes based on whether the cells in this column have a bit val of 0 or 1

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: 2008 bit data type problem

    I don't know if you can change the behaviour of the bit columns, but I guess using a short/tiny integer data type to store the 0 and 1 values should be fine. Expanding the scope usually doesn't break anything.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    123

    Re: 2008 bit data type problem

    thank you sir, i was thinking along the same lines myself, just wanted to get anothers opinion, i'm sending the current db over to the development server now and i'm going to convert everything there and run the program to see what happens

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: 2008 bit data type problem

    Quote Originally Posted by addntox View Post
    I restored a backup from SQL 2000 to SQL 2008R2, now in 2000 the bit value was 0 and 1, but 2008 designates it true/false. The software i'm using for this (it was specially developed) is returning errors because of this.
    That's not true. In SQL Server Management Studio, which was introduced with SQL Server 2005, bit values are displayed as True or False, but the data is still stored as 1 or 0 and, if you write a query in SSMS, you must use 1 or 0 for bit data. Even ADO.NET requires you to use 1 and 0 to represent bit literals.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    123

    Re: 2008 bit data type problem

    hrmm its looping through the table and returning an EOF BOF error saying current record doesnt exist is it possible originally it was using 1/-1 for true false?

  6. #6
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: 2008 bit data type problem

    One thing I know: It couldn't possibly use 1 and -1 to store true/false.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: 2008 bit data type problem

    I think it would be a good idea to show us the actual code, both VB and SQL that you're using. Presumably it's VB6, which I can't help with, but presumably there are others who can.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    123

    Re: 2008 bit data type problem

    example of a part where it errors

    code Code:
    1. Sub Combo_Trucker(Curform As Form, Index As Integer)
    2.     On Error GoTo errH
    3.     Dim strSQL As String
    4.     Dim lngsqlerr As Long
    5.     Dim rs As adodb.Recordset
    6.     Dim lp As Integer
    7.    
    8.     strSQL = "Select [INDEX],NAME from SUPPLIER Where TRUCKER=-1 and COMPID = " & AppComp & " order by ID"
    9.     lngsqlerr = Exec_SQL_RS_SRV(strSQL, rs)
    10.    
    11.     With Curform
    12.     For lp = 1 To Index
    13.         rs.MoveFirst
    14.         Do Until rs.EOF
    15.             .ComboTrucker(lp).AddItem rs!Name
    16.             .ComboTrucker(lp).ItemData(.ComboTrucker(lp).NewIndex) = rs![Index]
    17.             rs.MoveNext
    18.         Loop
    19.     Next lp
    20.     End With
    21.    
    22.     rs.Close
    23.     Set rs = Nothing
    24.     Exit Sub

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: 2008 bit data type problem

    What exactly does 'AppComp' contain? What data type is the TRUCKER column?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    123

    Re: 2008 bit data type problem

    trucker is the column that is set to bit type in SQL 2008

    COMPID is company ID (there's two companys operating in one separated by these flags/values)

    appcomp is which company app is running these are 0 (root admin) 1 (company 1)
    2 (company 2)

    so from what i can gather its filtering the what appears here depending on the corresponding flags the user has when logged in trucker is the only column where the data is different after importing to SQL 2008

    This thing has swallowed a week of my life this company went dead because they were running a 2000 server, had nothing backed up...so now i'm reconstructing this evil thing and this is the last thing standing in my way
    Last edited by addntox; Feb 3rd, 2011 at 03:31 AM.

  11. #11
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: 2008 bit data type problem

    I am still not able to understand why you are using -1 in the comparison.

    Try replacing -1 with either a 0 or with 'false' and see if the query then runs. For e.g.

    Code:
    "Trucker=0"
    or
    Code:
    "Trucker='false'"
    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  12. #12
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: 2008 bit data type problem

    when it comes to a bit type, 0 = false, 1= true. So using -1 shouldn't work (but does because True is generally defined as !0 ... which is why we can usually get away with things like myboolVal = recordset.Recordcount ... if RecordCount is 0, myBoolVale is assigned False... if it contains anything else, it is assigned True.

    My recommendation, if you want to check for false value in a bit field, use and explicit " = 0 " in the comparison. If you want true values, use an explicit not-zero comparison: " <> 0 "

    Code:
    strSQL = "Select [INDEX],NAME from SUPPLIER Where TRUCKER<>0 and COMPID = " & AppComp & " order by ID"
    Ovoid bit confusion.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    123

    Re: 2008 bit data type problem

    I didnt write the original program, and -1 worked in SQL2000, so god only knows. I've been brought in to get the app working. And since i've had little experience with VB6, i started out in .net there has been a learning curve...but i'm getting it. The plot thickens though i was able to get the comboboxes populate correctly setting it "=1" but here's the odd thing the -1 was returning the true state in the original program, so i dont know whether to just accept it and move on, or to figure out why the logic all seems backwards for my own peace of mind. Thanks for the help though guys i really appreciate it. I'm going to leave this unresolved for a little longer, the app is currently being put through its paces so i'm going to wait until they confirm it's fixed in operation i was working on a virtualization of their new domain as a safe environ, its on their main system today.

  14. #14
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: 2008 bit data type problem

    -1 IS a true state... ANY non-Zero value IS A TRUE STATE VALUE... which is why I use the method I mentioned above... when looking for false I use =0 ... looking for true values, I use <>0 ... then it doesn't matter. Now... in VB... I think there was a change from VB6 to .NET... where False was (and still is) 0... but in VB6, I think True was -1, while in .NET it's defined as 1 ... I may have that backwards... but for SQL, a bit is a bit... it can be only 0 or 1... so I don't know...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    123

    Re: 2008 bit data type problem

    ahh heheh i get it, so when the old program is sending -1 value to the new server running on the .net framework the server doesnt understand how to return that value, so its looping through the records and returning nothing. I can see why they changed it in .net. Much appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width