Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP/SQL Bit Datatype display issue

Posted on 2004-10-15
5
Medium Priority
?
324 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
[X]
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
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 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