Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access vs. SQL bit datatype  linked table

Posted on 2002-04-23
8
Medium Priority
?
246 Views
Last Modified: 2008-03-17
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?

0
Comment
Question by:Paullkha
8 Comments
 
LVL 8

Accepted Solution

by:
dovholuk earned 200 total points
ID: 6963066
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
 
LVL 8

Expert Comment

by:dovholuk
ID: 6963068
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
 
LVL 5

Expert Comment

by:spcmnspff
ID: 6963241
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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 32

Expert Comment

by:Brendt Hess
ID: 6963324
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 6979371
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
 
LVL 8

Expert Comment

by:dovholuk
ID: 6979503
i think it's good info.

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

dovholuk
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6981283
Thank you, finalized today.
Moondancer - EE Moderator
0
 
LVL 2

Author Comment

by:Paullkha
ID: 6983623
Seven days turnaround, damn, this is new. I do apologize.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question