|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
checkbox in datasetI have the following code : Dim Selectcol As New DataColumn Dim Updatecol As New DataColumn Dim Insertcol As New DataColumn Try 'my own class to fill the dataset (it works) m_dsFields = da.GetDataset 'add boolean column Select Selectcol.ColumnName = "Select" Selectcol.DataType = System.Type.GetType("System.Boolean") m_dsFields.Tables(0).Columns.Add(Selectcol) For iCntr As Integer = 0 To m_dsFields.Tables(0).Rows.Count - 1 m_dsFields.Tables(0).Rows(iCntr).Item("Select").value = True Next ..... I've got the followin error when the line .....value = True is called: Field 'value' of type 'DBNull' is 'ReadOnly'." What's wrong with my code ? Thx Hi,
Here is an example on how I do it Dim strConn As String Dim strSQL As String Dim daEmployees As OleDbDataAdapter Dim conn As OleDbConnection Dim ds As New DataSet strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" strConn &= "Data Source = Northwind.mdb;" conn = New OleDbConnection(strConn) daEmployees = New OleDbDataAdapter("Select * From Employees Order by LastName, FirstName", conn) daEmployees.Fill(ds, "Employees") Dim dcBool As New DataColumn("MyBool", GetType(Boolean)) ds.Tables("Employees").Columns.Add(dcBool) For Each dr As DataRow In ds.Tables("Employees").Rows dr.BeginEdit() dr.Item("MyBool") = True dr.EndEdit() Next DataGrid1.DataSource = ds.Tables("Employees") Ken ----------------- "Sam" <samuel.berthe***@voila.fr> wrote in message I have the following code :news:1113294690.194200.325800@o13g2000cwo.googlegroups.com... Hi, Dim Selectcol As New DataColumn Dim Updatecol As New DataColumn Dim Insertcol As New DataColumn Try 'my own class to fill the dataset (it works) m_dsFields = da.GetDataset 'add boolean column Select Selectcol.ColumnName = "Select" Selectcol.DataType = System.Type.GetType("System.Boolean") m_dsFields.Tables(0).Columns.Add(Selectcol) For iCntr As Integer = 0 To m_dsFields.Tables(0).Rows.Count - 1 m_dsFields.Tables(0).Rows(iCntr).Item("Select").value = True Next ..... I've got the followin error when the line .....value = True is called: Field 'value' of type 'DBNull' is 'ReadOnly'." What's wrong with my code ? Thx |
|||||||||||||||||||||||