Good Morning I have a little problem with my Program.
I have a table called period_closure
and this is what it looks like
+----------+-----------+------+
| PeriodID | Month | 2000 |
+----------+-----------+------+
| 1 | January | NULL |
| 2 | February | NULL |
| 3 | March | NULL |
| 4 | April | NULL |
| 5 | May | NULL |
| 6 | June | NULL |
| 7 | July | NULL |
| 8 | August | NULL |
| 9 | September | NULL |
| 10 | October | NULL |
| 11 | November | NULL |
| 12 | December | NULL |
+----------+-----------+------+
My goal here is to create a list of checkboxcolumn under the field 2000
but when i try it, it has an error saying Cannot change DataType of a column once it has data.
Here is my code
Dim con1 As MySqlConnection = New MySqlConnection("server=192.168.2.87;userid=root;password=admin1950;database=inventory")
Dim sql1 As MySqlCommand = New MySqlCommand("Select * from period_closure", con1)
Dim ds1 As DataSet = New DataSet
Dim adapter1 As MySqlDataAdapter = New MySqlDataAdapter
con1.Open()
adapter1.SelectCommand = sql1
adapter1.Fill(ds1, "MyTable")
DataGridView1.DataSource = ds1.Tables(0)
con1.Close()
ds1.Tables(0).Columns(2).DataType = GetType(Boolean)
Me.DataGridView1.Columns(0).Frozen = True
Dim i As Integer
For i = 0 To DataGridView1.Columns.Count - 1
DataGridView1.Columns.Item(i).SortMode = DataGridViewColumnSortMode.Programmatic
Next
How can I achieve it? and also just wanted to add that I will add more columns on it and my target is make all columns a checkboxcolumn except the Month
and PeriodID
Aucun commentaire:
Enregistrer un commentaire