Solved

ASP/SQL Bit Datatype display issue

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

947 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

22 Experts available now in Live!

Get 1:1 Help Now