473,396 Members | 1,785 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,396 software developers and data experts.

Get error when try to set DataColumn variable again

On the second call to the below method body, I get the error: A column
named 'Full Name' already belongs to this Data Table. In C++, what I
would do is either set col to null on exit from the method, or only do
the assignment if col is emply. Explicitly, how would I do these 2
things in VB?

Dim col As DataColumn

col = dsAdoSbs.Employees.Columns.Add("FullName",
System.Type.GetType("System.String"))

Thanks,
Christopher Lusardi

May 16 '06 #1
2 1065
Christopher Lusardi wrote:
On the second call to the below method body, I get the error: A column
named 'Full Name' already belongs to this Data Table. In C++, what I
would do is either set col to null on exit from the method, or only do
the assignment if col is emply. Explicitly, how would I do these 2
things in VB?

Dim col As DataColumn

col = dsAdoSbs.Employees.Columns.Add("FullName",
System.Type.GetType("System.String"))

Thanks,
Christopher Lusardi

Try deleting the column. Then you can add it again later.

T
May 16 '06 #2
Christopher,

There exist in Net the command "Add" and "Remove" column.

A pity is that you can save the column,

dim mycolumn as datatable.column = mydatatable.column(0)

but that does not contain the values in the items.

I hope this helps,

Cor

"Christopher Lusardi" <cl********@aol.com> schreef in bericht
news:11*********************@j55g2000cwa.googlegro ups.com...
On the second call to the below method body, I get the error: A column
named 'Full Name' already belongs to this Data Table. In C++, what I
would do is either set col to null on exit from the method, or only do
the assignment if col is emply. Explicitly, how would I do these 2
things in VB?

Dim col As DataColumn

col = dsAdoSbs.Employees.Columns.Add("FullName",
System.Type.GetType("System.String"))

Thanks,
Christopher Lusardi

May 17 '06 #3

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

Similar topics

0
by: Dave Elliott | last post by:
After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is after the newly added row without getting bizarre results. I have added the...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: Steve Richter | last post by:
here is an error I get when I open my class library project: "The class ResultsTable can be designed, but is not the first class in the file. Visual Studio requires that designers use the first...
20
by: MadCrazyNewbie | last post by:
Hey group, I keep getting the following error: "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll Additional information: There is no row at...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
1
by: explode | last post by:
My table has 5 columns: Broj iksice, Prezime, Ime, Broj indeksa, Broj pohadjanja. This is the code in the dataset designer VB made it by it self: Private Sub InitClass() Me.columnBroj_iksice =...
0
by: SMH | last post by:
Hi All, I am currently learning .Net 2, studying for 70-528. I've hit a bit of a brick wall with DataColumn.Expression. As I understand it, this can be used to (For example) concatenate two...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.