Access vs. SQL bit datatype linked table

I have a linked table in Access 2000 which is linked to a SQL table which has a bit datatype field called [FIELDBIT].
I want to pass this bit to a stored procedure call mysp using a pass-through qry as such:

sp_SQL = "EXECUTE mysp " & _
 "'" & arg1 & "'," & _
 "'" & arg2 & "'," & rs![FIELDBIT]
   
The value of rs!FIELDBIT is not 1 or 0(as it would be in sql) but True and False. So my pass-through qry translates to this:
EXECUTE mysp arg1,arg2, TRUE

SQL balks, converting nvarchar to bit. SQL would prefer this:
EXECUTE mysp arg1,arg2, 1

I know how to code a work-around. Abs(CInt(rs![FIELDBIT]))
My question is how to call the sp without a workaround?

LVL 2
PaullkhaAsked:
Who is Participating?
 
dovholukCommented:
there is no workaround.

you could experiment with creating a user-defined data type or something like that, but there's no need.  

instead of using true/false, you could change your check box to on/off. that should fix your issue too...

another point of interest (maybe), ANY number you send to SQL Server will be translated as true, so you shouldn't need to use the ABS() method in your example.

another "workaround" that's not as efficient as the one you already use, is to pass the argument as a string, then use the stored procedure to "validate" the string... although i don't see this as being a good idea at all... something like:

if @TrueOrFalse = 'FALSE'
   set @SomeOtherTrueOrFalseVariable = 0
else
   set @SomeOtherTrueOrFalseVariable = 1

*shrug* i think the "workaround" you're using now is the best method available...

good luck.

dovholuk
0
 
dovholukCommented:
as a side note, you have a few outstanding questions in other areas... you should try to clear these up.

help keep our EE "clean"

thanks,

dovholuk
0
 
spcmnspffCommented:
SQL Server implicitly coverts from NVarChar to Bit or integer to bit.  Bit is actually quite flexible.  If you try to update a bit field to anything other than 0 then the field becomes 1 (or on).  So the way I see it, you can code a workaround if you change the last parameter in your proc to a Int.  

Create Proc MySP
    @Arg1 VarChar(50),
    @Arg2 VarChar(50),
    @IntValue Int
AS

Now, with your quotes arranged the way they are, your string sp_sql in vb looks like this:

EXECUTE mysp 'arg1','arg2', -1

(The value true in vb is the integer value -1.)

So say you do an insert statement in you proc:

Insert Into MyTbl
(Arg1, Arg2, BitField)
Values @Arg1, @Arg2, @IntValue

Into the following table . . .

Create Table MyTbl
 Arg1 VarChar(50),
 Arg2 VarChar(50),
 BitField Bit

SQL Server will automatically do the following interpretation for the bit field:
                    0 - 0
Anything Other Than 0 - 1

Of course this would also work for an update statement.
=)                
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Brendt HessSenior DBACommented:
You can use your local engine to pass the correct data.  Use the IIF function:

sp_SQL = "EXECUTE mysp " & _
"'" & arg1 & "'," & _
"'" & arg2 & "'," & iif(rs![FIELDBIT],1,0)

This will pass 1 if True and 0 If not
0
 
MoondancerCommented:
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20292692.html
http://www.experts-exchange.com/questions/Q.20255048.html
http://www.experts-exchange.com/questions/Q.20284498.html
http://www.experts-exchange.com/questions/Q.20284957.html
http://www.experts-exchange.com/questions/Q.20293564.html

To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20089266.html

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 
dovholukCommented:
i think it's good info.

i'd say (humbily sp) to accept dovholuk comment as answer.

dovholuk
0
 
MoondancerCommented:
Thank you, finalized today.
Moondancer - EE Moderator
0
 
PaullkhaAuthor Commented:
Seven days turnaround, damn, this is new. I do apologize.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.