Results 1 to 6 of 6

Thread: [2005] Access YES/NO problem or Data Adapter problem?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    [2005] Access YES/NO problem or Data Adapter problem?

    I'm using an SQL statement to try and run an Update statement to an Access database. Unfortunately I have to mess with a YES/NO field aka boolean. Here's my current statement:

    UPDATE [table1] SET field1 = 'blah',field2 = 'blahblah',TorF = no WHERE num = 289

    now I've tried yes, no, 0, 1, True, and False and every one of them result in a "data mismatch type." Now I looked this up extensively online and some sources say 0 and 1 should work and others say True and False out of single quotes should work. So is there some sort of VB data adapter or other ADO problem going on here that's interfering with it? I thought the data adapter will send anything even if I sent it an SQL string of "hey go do some databasey stuff, alright?" and let the DB handle it but then again it it specifically an OLEDB adapter. So yeah I'm sure someone here has at some point had to deal with the yes/no field so what worked for you?
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

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

    Re: [2005] Access YES/NO problem or Data Adapter problem?

    It's 0.....
    Post your code... it maybe the way you are setting it up or calling it... sometimes the answer isn't where it seems.

    -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??? *

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    Re: [2005] Access YES/NO problem or Data Adapter problem?

    well I put in 0 and read the error a little more carefully and it turns out that the value for the WHERE test is actually text. I put it in single quotes and now I'm having another nightmare of a problem that's unrelated :P can't really tell if the 0 works but I think like 1/3 of the loop worked without failing so maybe it does
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

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

    Re: [2005] Access YES/NO problem or Data Adapter problem?

    A Yes/No column contains boolean values. You should using True and False without single quotes. I'm assuming that when you used True and False your data type mismatch was coming from the WHERE clause.
    Code:
    INSERT table1 SET field1= 'blah', filed2 = 'blahblah', TorF = False WHERE num = '289'
    SQL Server bit columns use 0 and 1.
    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
    Member
    Join Date
    Nov 2006
    Posts
    38

    Re: [2005] Access YES/NO problem or Data Adapter problem?

    Quote Originally Posted by jmcilhinney
    A Yes/No column contains boolean values. You should using True and False without single quotes. I'm assuming that when you used True and False your data type mismatch was coming from the WHERE clause.
    Code:
    INSERT table1 SET field1= 'blah', filed2 = 'blahblah', TorF = False WHERE num = '289'
    SQL Server bit columns use 0 and 1.
    use paramaters in your update command. it will better parse a boolean value

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

    Re: [2005] Access YES/NO problem or Data Adapter problem?

    Quote Originally Posted by nick2k3
    use paramaters in your update command. it will better parse a boolean value
    If you're inserting a variable into the SQL statement then you should use parameters regardless of the type. If you're using a literal value then you would use a boolean literal.
    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

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