Solved

ASP/SQL Bit Datatype display issue

Posted on 2004-10-15
5
317 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
Comment Utility
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
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now