473,325 Members | 2,308 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,325 software developers and data experts.

Error when adding row to dataset

I have a dataset that I created programmatically and bind to a datagrid.
When I add a row and I .show the form I get an error "Error creating window
handle"

This only happens if I have the code to add the row active. If I comment it
out then the form loads successfully (without any records, obviously).

Below is the code:

'-----------------------------Code Starts
Here----------------------------------

Dim dsCategories As New DataSet
Dim tbl_Categories As New DataTable
tbl_Categories.Columns.Add("CatNumber",
System.Type.GetType("System.String"))
tbl_Categories.Columns.Add("CatName",
System.Type.GetType("System.String"))
tbl_Categories.Columns.Add("CatCode",
System.Type.GetType("System.String"))

Dim drCurRow As DataRow = dsCategories.Tables("tbl_Categories").NewRow
drCurRow("CatNumber") = "1"
drCurRow("CatName") = "Regular"
drCurRow("CatCode") = "110"
dsCategories.Tables("tbl_Categories").Rows.Add(drC urRow)

grdCategories.DataSource = dsCategories

'---------------------------------Code Ends
Here--------------------------------
I Hope this is the right newsgroup to post this.
--
Thank you for your help
Nov 21 '05 #1
6 1174
Dacuna,

I miss one statement
Dim dsCategories As New DataSet
Dim tbl_Categories As New DataTable


dsCategories.tables.add(tbl_Categories)

Do you have that one somewhere?

I hope this helps?

Cor
Nov 21 '05 #2
I noticed that I was that missing, but even after I added that line of code
it did not correct the problem. What DID correct the problem was replacing

Dim drCurRow As DataRow = dsCategories.Tables("tbl_Categories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Tables(0).NewRow

which does not make sense because I would think it would mean the same.

Now I have a datagrid problem/question. Are you familiar with the control?
It has to do with expanding all the way instead of having to click on the
plus sign to expand the view to show the content of the table ( I hope I'm
making sense)

Do you know of a tutorial in how to use the datagrid that I can read through?

THanks,

Danny
"Cor Ligthert" wrote:
Dacuna,

I miss one statement
Dim dsCategories As New DataSet
Dim tbl_Categories As New DataTable


dsCategories.tables.add(tbl_Categories)

Do you have that one somewhere?

I hope this helps?

Cor

Nov 21 '05 #3
Danny,

I do them error by error, I saw the one I showed you and than I stopped
looking, however did as well not understand why it gave the error, but it is
needed when you use it as datasouce although than you see only that nasty +
and nothing more

When you would have done the change below you would as well have avoided the
error
Dim tbl_Categories As New DataTable("tbl_Categories")

And than to answer your next included question it can be
datasource = dsCategories.tables(0)
or when you have changed is as above
datasource = dsCategories.tables("tbl_Categories")
or when you do not add the datatable at all to the dataset
datasource = tbl_Categories

There are nice samples in the resourcekit for the datagrid, however I know
that there are problems with standard opening the samples, so you have to go
around that. (It are complete projects so easy to find).

VB.net Resource kit
http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing the resource kit
http://msdn.microsoft.com/vbasic/vbr...q/#installvdir
I hope this helps?

Cor

"Dacuna" <da****@houston.rr.SAYNOTOSPAM.com>
I noticed that I was that missing, but even after I added that line of code
it did not correct the problem. What DID correct the problem was
replacing

Dim drCurRow As DataRow = dsCategories.Tables("tbl_Categories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Tables(0).NewRow

which does not make sense because I would think it would mean the same.

Now I have a datagrid problem/question. Are you familiar with the
control?
It has to do with expanding all the way instead of having to click on the
plus sign to expand the view to show the content of the table ( I hope I'm
making sense)

Do you know of a tutorial in how to use the datagrid that I can read
through?

THanks,

Danny
"Cor Ligthert" wrote:
Dacuna,

I miss one statement
> Dim dsCategories As New DataSet
> Dim tbl_Categories As New DataTable


dsCategories.tables.add(tbl_Categories)

Do you have that one somewhere?

I hope this helps?

Cor

Nov 21 '05 #4
Regarding having to click the plus sign to expand the view.... How many
tables are you showing in the Grid? If you are just showing one table, then
bind the table to your datagrid and not the dataset. This will make it so
the table shows fully expanded.

Chris

"Dacuna" <da****@houston.rr.SAYNOTOSPAM.com> wrote in message
news:0E**********************************@microsof t.com...
I noticed that I was that missing, but even after I added that line of code
it did not correct the problem. What DID correct the problem was
replacing

Dim drCurRow As DataRow = dsCategories.Tables("tbl_Categories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Tables(0).NewRow

which does not make sense because I would think it would mean the same.

Now I have a datagrid problem/question. Are you familiar with the
control?
It has to do with expanding all the way instead of having to click on the
plus sign to expand the view to show the content of the table ( I hope I'm
making sense)

Do you know of a tutorial in how to use the datagrid that I can read
through?

THanks,

Danny
"Cor Ligthert" wrote:
Dacuna,

I miss one statement
> Dim dsCategories As New DataSet
> Dim tbl_Categories As New DataTable


dsCategories.tables.add(tbl_Categories)

Do you have that one somewhere?

I hope this helps?

Cor

Nov 21 '05 #5
Your suggestions worked perfectly.

I'll check out the links

Thanks,
Danny

"Cor Ligthert" wrote:
Danny,

I do them error by error, I saw the one I showed you and than I stopped
looking, however did as well not understand why it gave the error, but it is
needed when you use it as datasouce although than you see only that nasty +
and nothing more

When you would have done the change below you would as well have avoided the
error
Dim tbl_Categories As New DataTable("tbl_Categories")

And than to answer your next included question it can be
datasource = dsCategories.tables(0)
or when you have changed is as above
datasource = dsCategories.tables("tbl_Categories")
or when you do not add the datatable at all to the dataset
datasource = tbl_Categories

There are nice samples in the resourcekit for the datagrid, however I know
that there are problems with standard opening the samples, so you have to go
around that. (It are complete projects so easy to find).

VB.net Resource kit
http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing the resource kit
http://msdn.microsoft.com/vbasic/vbr...q/#installvdir
I hope this helps?

Cor

"Dacuna" <da****@houston.rr.SAYNOTOSPAM.com>
I noticed that I was that missing, but even after I added that line of code
it did not correct the problem. What DID correct the problem was
replacing

Dim drCurRow As DataRow = dsCategories.Tables("tbl_Categories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Tables(0).NewRow

which does not make sense because I would think it would mean the same.

Now I have a datagrid problem/question. Are you familiar with the
control?
It has to do with expanding all the way instead of having to click on the
plus sign to expand the view to show the content of the table ( I hope I'm
making sense)

Do you know of a tutorial in how to use the datagrid that I can read
through?

THanks,

Danny
"Cor Ligthert" wrote:
Dacuna,

I miss one statement
> Dim dsCategories As New DataSet
> Dim tbl_Categories As New DataTable

dsCategories.tables.add(tbl_Categories)

Do you have that one somewhere?

I hope this helps?

Cor


Nov 21 '05 #6
Ah...perfect. Good point.

Quite a learning curve from ADO to ADO.NET

Thanks for your help

"Chris, Master of All Things Insignifican" wrote:
Regarding having to click the plus sign to expand the view.... How many
tables are you showing in the Grid? If you are just showing one table, then
bind the table to your datagrid and not the dataset. This will make it so
the table shows fully expanded.

Chris

"Dacuna" <da****@houston.rr.SAYNOTOSPAM.com> wrote in message
news:0E**********************************@microsof t.com...
I noticed that I was that missing, but even after I added that line of code
it did not correct the problem. What DID correct the problem was
replacing

Dim drCurRow As DataRow = dsCategories.Tables("tbl_Categories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Tables(0).NewRow

which does not make sense because I would think it would mean the same.

Now I have a datagrid problem/question. Are you familiar with the
control?
It has to do with expanding all the way instead of having to click on the
plus sign to expand the view to show the content of the table ( I hope I'm
making sense)

Do you know of a tutorial in how to use the datagrid that I can read
through?

THanks,

Danny
"Cor Ligthert" wrote:
Dacuna,

I miss one statement
> Dim dsCategories As New DataSet
> Dim tbl_Categories As New DataTable

dsCategories.tables.add(tbl_Categories)

Do you have that one somewhere?

I hope this helps?

Cor


Nov 21 '05 #7

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

Similar topics

2
by: Ian Griffiths | last post by:
I have been given a schema, instances of which I'm required to be able to consume and generate. I'd like to be able to manipulate these instances as DataSets internally in my application. The...
2
by: a | last post by:
I get the error that "Argument"1": cannot convert from 'string' to 'System.Data.DataRow' at the foreach loop to add rows to the DataTable...any ideas how to fix this? Paul ...
0
by: Susil Patro | last post by:
Hi all, I have installed Visual Studio dot net version 2003, in my machine. I opened a new project for developing an application related to crystal reports. I got the following error, while I...
6
by: Mark | last post by:
I'm trying to add a table to a dataset but get the error: "A DataTable named 'BordDates0040' already belongs to this DataSet." Code: Dim dtBordDates As DataTable dtBordDates =...
2
by: RSH | last post by:
I have a rather simple script that transfers data from a SQL server database to an Access database. The procedure is intended to be dynamic so I am basically adding a datarow and then passing the...
0
by: David | last post by:
I am trying to migrate a .net 1.1 Web Application to a 2.0 Web Application. I am experiencing issues when putting a strongly typed dataset into session, and then navigation to a page where...
5
by: Ryan | last post by:
A binding navigator control adds the following code for when the Save button is clicked: Me.Validate() Me.UserBindingSource.EndEdit() Me.UserTableAdapter.Update(Me.UserDataSet.User)" You can...
17
by: =?Utf-8?B?SGVyYg==?= | last post by:
I have created a report and subreport in VB/ASP.NET. The report works fine but the subreport will not display. The subreport, when displayed as a standalone report, works fine. Any help I can...
3
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Solved it. I had to rewrite my classes in my business & datalayer changing their constructors. Julia "Julia B" wrote:
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...
1
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: 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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.