Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 June 5th, 2006, 02:46 AM
Authorized User
 
Join Date: Apr 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vivekshah Send a message via Yahoo to vivekshah
Default Problem inserting value from Check Box

Hi ALL

I have a SQL Server table customer which has fields regarding details of customer.
I added one column IsCorporate of data type bit with Default(0).

Now on the form that gets all details of customer there i have an checkbox
"Is Coprorate".

I tried the following way to insert in the query.
Code:
insert into customer (IsCorporate) VAlues (+((chkCorporate.Checked==true)?1:0)+);
on executing this Query there is no response from the server.

What could be the problem?

Vivek Shah
__________________
Vivek Shah
 
Old June 6th, 2006, 02:15 PM
Authorized User
 
Join Date: Feb 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MAKO
Default

The problem, I think, is that you're using a ternary operator to check for your checkbox value. The ternary operator is used for assingment to variables depending on certain condition. To use the ternary in your code, you should change it to:

Code:
bit check;
check = (chkCorporate.Checked)? 1:0;
insert into customer (IsCorporate) VAlues (check);

MAKO - "El super simio"
 
Old June 6th, 2006, 02:32 PM
Authorized User
 
Join Date: Feb 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MAKO
Default

Sorry, that code should have read like this:

Code:
bit check;
check = (chkCorporate.Checked)? 1:0;
"insert into customer (IsCorporate) VAlues (" + check + ");";
MAKO - "El super simio"
 
Old June 8th, 2006, 08:17 AM
Authorized User
 
Join Date: Apr 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vivekshah Send a message via Yahoo to vivekshah
Default

thanks this works efficiently


Vivek Shah





Similar Threads
Thread Thread Starter Forum Replies Last Post
check box problem Vince_421 Access VBA 3 March 1st, 2007 04:35 PM
check box problem Scripts82 Access VBA 4 April 19th, 2006 03:48 AM
problem reciving check box values using post metho method Pro PHP 1 March 10th, 2006 08:27 PM
How do I check a db before inserting a record? Lucy SQL Server ASP 3 April 25th, 2005 10:47 PM
how to get value from check box..... cici Classic ASP Professional 2 May 15th, 2004 08:35 AM





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