Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 5th, 2006, 02:46 AM
Authorized User
 
Join Date: Apr 2006
Location: Jamnagar, Gujarat, India.
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
Reply With Quote
  #2 (permalink)  
Old June 6th, 2006, 02:15 PM
Authorized User
 
Join Date: Feb 2006
Location: Bluefields, , .
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"
Reply With Quote
  #3 (permalink)  
Old June 6th, 2006, 02:32 PM
Authorized User
 
Join Date: Feb 2006
Location: Bluefields, , .
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"
Reply With Quote
  #4 (permalink)  
Old June 8th, 2006, 08:17 AM
Authorized User
 
Join Date: Apr 2006
Location: Jamnagar, Gujarat, India.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:30 PM.


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