Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CheckBox and DataSet/DataBase

Posted on 2004-11-06
3
Medium Priority
?
246 Views
Last Modified: 2010-04-24
Hi,

This is the first time I'm using the CheckBox Control and have to write it's state to a (boolean) DataSet field .

This is the way I'm doing it:

chbSuspend is the CheckBox' name.

Dim dr As DataRow = DsProducts1.Tables("tProducts").NewRow

        If chbSuspend.CheckState = CheckState.Checked Then
            dr("Discontinued") = chbSuspend.Checked.TrueString
        Else : dr("Discontinued") = chbSuspend.Checked.FalseString
        End If

        DsProducts1.Tables("tProducts").Rows.Add(dr)

The updating of the DataSet/DataBase does'nt work. Obviously handling boolean data is the problem.

Can somebody help me? Any help shall be greatly appreciated.

0
Comment
Question by:Ghanisen
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 1500 total points
ID: 12514796
Here is an example how to write to boolean field in ds

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
#End Region

    Private WithEvents myDataTable As New DataTable("Test")
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        DataGrid1.DataSource = myDataTable
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        myDataTable.Columns.Add("Forename", System.Type.GetType("System.String"))
'---------------------------------------------------------------
        myDataTable.Columns.Add("Status", System.Type.GetType("System.Boolean"))
'---------------------------------------------------------------
        myDataTable.Columns.Add("Lastname", System.Type.GetType("System.String"))
        myDataTable.Rows.Add(New Object() {"Mary", True, "Sullivan"})
        myDataTable.Rows.Add(New Object() {"John", False, "Peterson"})
        myDataTable.Rows.Add(New Object() {"Jim", True, "Bergman"})
        myDataTable.AcceptChanges()
    End Sub
    Private Sub myRowChanging(ByVal sender As Object, ByVal e As DataRowChangeEventArgs) Handles myDataTable.RowChanging
        MessageBox.Show("RowChanging")
    End Sub
    Private Sub myColumnChanging(ByVal sender As Object, ByVal e As DataColumnChangeEventArgs) Handles myDataTable.ColumnChanging
        MessageBox.Show("ColumnChanging")
    End Sub

End Class

0
 

Author Comment

by:Ghanisen
ID: 12515081
Hi iboutchkine,

 I have found a simpler method that works :

Dim dr As DataRow = DsProducts1.Tables("tProducts").NewRow

....... 'Code for other rows

dr("Discontinued") = chbSuspend.CheckState

.......'Code for other rows

DsProducts1.Tables("tProducts").Rows.Add(dr)

But I still have one problem: For the column ("Discontinued") I get in my DataGrid "False" or "True" in English whereas my end users speak French. Do you know how I can get the DataGrid to show "Vrai" and "Faux" instead of "True" and "false"?

Thanks for your help.
 




0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12515341
I am not very familiar with this, but check CultureInfo class

The CultureInfo class holds culture-specific information, such as the associated language, sublanguage, country/region, calendar, and cultural conventions. This class also provides access to culture-specific instances of DateTimeFormatInfo, NumberFormatInfo, CompareInfo, and TextInfo. These objects contain the information required for culture-specific operations, such as casing, formatting dates and numbers, and comparing strings.

something like

 ci = New CultureInfo("en-US")' here use french
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question