Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ASP/SQL Bit Datatype display issue

Posted on 2004-10-15
5
320 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
API works for 1 result, need to make it many 30 92
Generate report pulling data (links) from three tables 31 66
If-Then-Else ASP problem 6 67
html Uncheck Checkbox 2 25
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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