Home All Groups Group Topic Archive Search About
Author
12 Apr 2005 8:31 AM
Sam
Hi,
I 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

Author
12 Apr 2005 4:33 PM
Ken Tucker [MVP]
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
news:1113294690.194200.325800@o13g2000cwo.googlegroups.com...
Hi,
I 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
Author
13 Apr 2005 7:44 AM
Sam
Thanks , I had solved my problem this way indeed.