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

x
?
Solved

ASP/SQL Bit Datatype display issue

Posted on 2004-10-15
5
Medium Priority
?
326 Views
Last Modified: 2012-06-27
I have a table, SQL Svr 2000. That table has a column, datatype = bit. I am able to both update and insert into this table with 1's and 0's, no problem.

If I run a select against the table (as in 'select * from table') and output the value of that column, the following occurs:

If the value in the column is 1, I'm able to display 'True' like so:
response.write objRS("columnName")

If the value in the column is 0, that same response.write elicits the following response:

  Microsoft VBScript runtime (0x800A000D)
  Type mismatch

Why doesn't the response.write work with a 'false' return?

PLEASE HELP ASAP!!
0
Comment
Question by:Paul Kahl
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 12325544
Response.write CBool(objRS("columnName"))


The issue is interesting though, i'll have a look into it.
0
 
LVL 3

Author Comment

by:Paul Kahl
ID: 12325565
Response.write CBool(objRS("columnName"))

produces the same error. As long as the result from the field is false, I can't do anything with it. There must be some way to output 0 values from a bit column in a sql db on an asp page.
0
 
LVL 28

Expert Comment

by:sybe
ID: 12325580
Ok, i think i know what the error is (and why i never met it), it requires the Value property:
<%
response.write objRS("columnName").Value
%>


you can also try:

<%
If Not objRS("columnName").Value The Response.write "True"
%>
0
 
LVL 28

Accepted Solution

by:
sybe earned 2000 total points
ID: 12325590
sorry:

If Not objRS("columnName").Value The Response.write "False"

I use a CheckBoolean function
<%
Response.write CheckBoolean(objRS("columnName").Value)

Function CheckBoolean(ByVal v)
    CheckBoolean = False
    If v Then CheckBoolean = True
End Function

%>
0
 
LVL 3

Author Comment

by:Paul Kahl
ID: 12325717
Thanks a bunch for offering the help. What managed to fix the issue in the end was to change my select statement from 'select *from...' to 'select colName from' - specifically including each column name in the select - apparently they just won't display if they aren't a part of the full select. It's annoying to be sure.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

971 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