473,322 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

CheckBox question

I have a winform with a checkbox on it. The editor is named CBXE30.
I have it bound to a bit field in SQL Server 2000. In design mode, in the
databindings section of the control I have the Checked property set to
DsMain1 - Contracts.E30.

The binding appears to be working correctly because if I bring a certain
record to the WinForm where I know that the E30 Column in the Database is
equal to 1, the CBXE30 checkbox on the form appears checked. If I bring it
to the screen and I know ahead of time that the E30 column in the db equals
0, the CBXE30 checkbox appears unchecked.

The problem comes when I make a change to the CheckBox. If I check or
uncheck it and try to post the record to the database I get an error message
of "Error converting the VarChar value T to a column of data type bit".

What's going on here? Do I need to write some code in one or more of the
events associated with the checkbox. If so, what event and what code should
I write. I would like this to be a 3 state checkbox.
Nov 20 '05 #1
3 1341
Woody

Show us the code in the Update Stored Procedure
--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================
Pocket PC Return On Investment Calculator
Free Download http://64.78.34.175/mcsnet/kwickKalk1.aspx

"Woody Splawn" <wo***@splawns.com> wrote in message
news:ek**************@TK2MSFTNGP11.phx.gbl...
I have a winform with a checkbox on it. The editor is named CBXE30.
I have it bound to a bit field in SQL Server 2000. In design mode, in the
databindings section of the control I have the Checked property set to
DsMain1 - Contracts.E30.

The binding appears to be working correctly because if I bring a certain
record to the WinForm where I know that the E30 Column in the Database is
equal to 1, the CBXE30 checkbox on the form appears checked. If I bring it to the screen and I know ahead of time that the E30 column in the db equals 0, the CBXE30 checkbox appears unchecked.

The problem comes when I make a change to the CheckBox. If I check or
uncheck it and try to post the record to the database I get an error message of "Error converting the VarChar value T to a column of data type bit".

What's going on here? Do I need to write some code in one or more of the
events associated with the checkbox. If so, what event and what code should I write. I would like this to be a 3 state checkbox.

Nov 20 '05 #2
Woody...

Lets see the Update Code in the stored procedure

--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================
Pocket PC Return On Investment Calculator
Free Download http://64.78.34.175/mcsnet/kwickKalk1.aspx
"Woody Splawn" <wo***@splawns.com> wrote in message
news:ek**************@TK2MSFTNGP11.phx.gbl...
I have a winform with a checkbox on it. The editor is named CBXE30.
I have it bound to a bit field in SQL Server 2000. In design mode, in the
databindings section of the control I have the Checked property set to
DsMain1 - Contracts.E30.

The binding appears to be working correctly because if I bring a certain
record to the WinForm where I know that the E30 Column in the Database is
equal to 1, the CBXE30 checkbox on the form appears checked. If I bring it to the screen and I know ahead of time that the E30 column in the db equals 0, the CBXE30 checkbox appears unchecked.

The problem comes when I make a change to the CheckBox. If I check or
uncheck it and try to post the record to the database I get an error message of "Error converting the VarChar value T to a column of data type bit".

What's going on here? Do I need to write some code in one or more of the
events associated with the checkbox. If so, what event and what code should I write. I would like this to be a 3 state checkbox.

Nov 20 '05 #3
Hi Woody,

Based on my understanding ,you bind a checkbox onto a bit type field. When
you update the change to the database,you encounter the "Error converting
the VarChar value T to a column of data type bit" error.

Here is my code.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.SqlDataAdapter1.Fill(Me.DataSet11)
'Databinding to the checkbox
Me.CheckBox1.DataBindings.Add("Checked", Me.DataSet11,
"Table1.BITDATA")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
BindingContext(DataSet11, "Table1").EndCurrentEdit()
Me.SqlDataAdapter1.Update(Me.DataSet11)
End Sub

This is the schema of my dataset ( The dataset has two field, one is ID (
int), the other is BITDATA(bit).

<?xml version="1.0" standalone="yes" ?>
<xs:schema id="DataSet1"
targetNamespace="http://www.tempuri.org/DataSet1.xsd"
xmlns:mstns="http://www.tempuri.org/DataSet1.xsd"
xmlns="http://www.tempuri.org/DataSet1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="DataSet1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Table1">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="BITDATA" type="xs:boolean" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Table1" />
<xs:field xpath="mstns:ID" />
</xs:unique>
</xs:element>
</xs:schema>

If you hope the checkbox to a three state, you may need to bind the
checkstate to a int type, since the bit type can not be binded to the
checkstate which is a enumerate type with three values.

If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jay | last post by:
Hi everybody ! I am currently writing a webpage that displays a list of records ( each record has a checkbox associated with it) to allow users to select any record they want to delete (much...
0
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
2
by: Fred | last post by:
Hi, I defined a form consisting of checkboxes like: <form> <input type="checkbox" name=ck id=ck onclick="check(this.form)" <input type="checkbox" name=ck id=ck onclick="check(this.form)" ........
10
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox...
4
by: Matrixreloadedth | last post by:
How to change disable color of Checkbox??? I have a checkbox with forecolor in red but when i disable by set Enable properties to false forecolor is changed to gray color but i don't want it. how...
34
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript...
5
by: FP | last post by:
I have a list of results. When the user clicks a checkbox I need it to update the database but I don't want it to reload the current page. Currently I have the following; - a checkbox in a form...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
3
by: chiku1523 | last post by:
Hi, Please find the following code. In function setAnswers, I am looping with each question. I have inner loop, which is looping for each answers of the questions. If any of the answer for question...
1
Death Slaught
by: Death Slaught | last post by:
I play a game that when your backpack fills with items (the limit is 45) you must choose items to discard by unchecking their box. This is very annoying and time consuming so I was wondering if it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.