473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

checkbox in dataset

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").va lue = 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

Nov 21 '05 #1
2 2834
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" <sa**************@voila.fr> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.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").va lue = 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
Nov 21 '05 #2
Sam
Thanks , I had solved my problem this way indeed.

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: michael walser | last post by:
display checkbox in datagrid. I find that there are 3 status: checked - check box with click icon unchecked - blank in check box unknown - click icon but color in gray..... How can I set the...
2
by: Sebi | last post by:
Hello all is it possible to add a checkbox in a DataGrid for Boolean Data? Thanks in advance
3
by: Moe Sizlak | last post by:
Hi, Can I check a checkbox by default based on the value returned from a database? for example if the value (dr("frm7value")) returned from a db field is "YES" how can I check the checkbox by...
1
by: sneha123 | last post by:
There will be some 20 questions and for each question there will be 4 choices.what i want to do is to select multiple answers by clicking the checkbox. i m using asp.net,vb.net pls help me we...
2
by: Nu2ASP.NET | last post by:
What I am trying to do is essentially 'flip' the bits, when the user clicks in the checkbox. For example, if the CheckBox appears checked, and the user un-checks it, I want the underlying data...
4
by: magmo | last post by:
Hi I have created a windows form that hold a datagrid, that datagrid gets it values from a stored procedure. My problem is that I have added a checkbox to the datagrid and applied some style...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
1
by: whidbey | last post by:
Hello friends, I am whidbey, new to thescripts and dot net as well.I am working over Online Shopping Cart,web application.I design a page (webform5.aspx) where user search books then select the books...
0
by: whidbey | last post by:
Hello friends, I am whidbey, new to thescripts and dot net as well.I am working over Online Shopping Cart,web application.I design a page (webform5.aspx) where user search books then select the books...
3
by: Chris McGrath | last post by:
Hello all, I have a gridview that contains a checkbox for each row and in each row, one of the fields is an asp:HyperLinkField. What I am trying to do is allow a user to click the link and...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.