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.