Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2004, 03:14 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Boolean in ASP.NET with SQL Server

Hello
I am using SQL Server to store Data. When I want to store Boolean values in SQL Server with ASP.NET what is the DataType equivalent to this in SQL. In other words what is the easiest way to store Boolean in SQL without hassles of changing datatype. Can I use Bit????

I have been assigning a string value of T for True and F for False but I have to change this in ASP.NET before storing it as varchar (1) in SQL. There has to be a better way. Thanks.

 
Old September 24th, 2004, 10:28 AM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, you can use bit. Then you can use something like

Dim da As New SqlDataAdapter("SELECT field FROM table", "Provider=...")
Dim ds As New DataSet

da.Fill(ds)

Dim BooleanReturned As Boolean = CBool(ds.Tables(0).Rows(0).Item("field")


Devjunkies.com
 
Old September 27th, 2004, 09:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I haven't had any problems passing boolean values to a bit field back and forth.

Brian
 
Old September 28th, 2004, 11:10 AM
Authorized User
 
Join Date: Sep 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zouky
Default

well, my question also related with bekim.
if on my web form i using treeview, once i cehck on any particular treenode, just assume my default value and uncheck the checkbox on treenode is false; checked changed for true. how should i using any method that can convert the bit (datatype on the field) to represent yes/no?

i using this for granting privilege to my usergroup, once i check the treenode, then they can have the access on the system.

thank you, i need the inspiration

 
Old September 28th, 2004, 01:03 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

When you say yes/no, you really mean True/False (boolean values) correct? ADO.NET should convert these values for you, so boolean is converted to bit, and vice versa.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET 1.1,VB.NET,crystal reports, SQl server gvi Crystal Reports 1 September 11th, 2008 02:55 AM
Xml from SQL Server into ASP.NET toddw607 ASP.NET 2.0 Basics 4 June 4th, 2007 08:57 AM
How to get Image from sql Server in Asp.net akumarp2p C# 2005 1 February 22nd, 2007 09:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.