Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 24th, 2004, 10:25 PM
mspx40 mspx40 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 mspx40 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
XML Boolean value to SQL Server BIT

I am working on an application written in Visual FoxPro 7 that produces an XML file of a recordset. One of the fields in this XML file is type="xsd:boolean" with a value of "false". My application then calls a SQL Server stored procedure that does a bulk update using this XML file(converted to a stream) and OPENXML(). Unfortunately, the corresponding field in the SQL database is BIT. When I run the stored procedure I get an error: Syntax error converting the nvarchar value 'false' to a column of datatype BIT. The XML stream has schema information that clearly defines this field as BOOLEAN.
How can I get around this datatype inconsistency - type conversions,etc.

Reply With Quote
  #2  
Old July 1st, 2004, 09:34 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,002 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 19 h 40 m 17 sec
Reputation Power: 105
You could always convert it on the fly:

Code:
Function Bool2Bit(bool_Value)
 Select Case bool_Value
  Case True
   Bool2Bit = 1
  Case False
   Bool2Bit = 0
 End Select
End Function


Now you can embed this in your SQL string construction:

Code:
str_SQL = "INSERT INTO Database (TrueOrFalse) VALUES (" & Bool2Bit(xml_BooleanValue) & ");"

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > XML Boolean value to SQL Server BIT


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT