473,563 Members | 2,709 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error when adding row to dataset

I have a dataset that I created programmaticall y 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("Ca tNumber",
System.Type.Get Type("System.St ring"))
tbl_Categories. Columns.Add("Ca tName",
System.Type.Get Type("System.St ring"))
tbl_Categories. Columns.Add("Ca tCode",
System.Type.Get Type("System.St ring"))

Dim drCurRow As DataRow = dsCategories.Ta bles("tbl_Categ ories").NewRow
drCurRow("CatNu mber") = "1"
drCurRow("CatNa me") = "Regular"
drCurRow("CatCo de") = "110"
dsCategories.Ta bles("tbl_Categ ories").Rows.Ad d(drCurRow)

grdCategories.D ataSource = dsCategories

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

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


dsCategories.ta bles.add(tbl_Ca tegories)

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.Ta bles("tbl_Categ ories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Ta bles(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.ta bles.add(tbl_Ca tegories)

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.ta bles(0)
or when you have changed is as above
datasource = dsCategories.ta bles("tbl_Categ ories")
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.Ta bles("tbl_Categ ories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Ta bles(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.ta bles.add(tbl_Ca tegories)

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******** *************** ***********@mic rosoft.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.Ta bles("tbl_Categ ories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Ta bles(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.ta bles.add(tbl_Ca tegories)

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.ta bles(0)
or when you have changed is as above
datasource = dsCategories.ta bles("tbl_Categ ories")
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.Ta bles("tbl_Categ ories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Ta bles(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.ta bles.add(tbl_Ca tegories)

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******** *************** ***********@mic rosoft.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.Ta bles("tbl_Categ ories").NewRow

with

Dim drCurRow As DataRow = dsCategories.Ta bles(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.ta bles.add(tbl_Ca tegories)

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
6694
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 schema defines the following simpleType: <xs:simpleType name="cs"> <xs:restriction base="xs:token"> <xs:pattern value="*"/> </xs:restriction>...
2
5504
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 ================================================== private void button1_Click(object sender, System.EventArgs e) {
0
1317
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 tried to add a new dataset "The daVinci Diagram Surface could not be found. Please reinstall Visual Studio".
6
2222
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 = LoadTable(strDBPath & strDBName, strTableName, strSQL) Dim ds2 As DataSet = New DataSet()
2
2801
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 data with a simple loop. I am using OleDbCommandbuilder to build the INSERT command but for some reason when it gets to a particular table in the...
0
1344
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 aspcompat is set to "true". I can reproduce the problem by creating a brand new web site project in VS2005, and creating a new page where I set...
5
3919
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 add code to the column changing event for the dataset by using the dataset designer, for example: Private Sub UserDataTable_ColumnChanging(ByVal...
17
20314
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 find on this error refers to the WinForms.ReportViewer and none to the WebForms.ReportViewer. Anyone have any guidance?
3
1579
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
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.