473,473 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Adding PrimaryKey to a DataTable

Hi.
This is my problem. I'm filling a DataTable with data from my DB. The
problem is that none of the data is unique, not even combined. So I was
wondering if it is possible to add a unique column (AutoIncrement) to the
DataTable after (or before) I fill it with data?

Thanks,
Shawn
Nov 19 '05 #1
1 1365
Shawn,

You can always do it in the code after populating the table from the
database. Reserve a column for the index and, after you got the data, loop
through the rows and set the index column value.

Eliyahu

"Shawn" <bo********@hotmail.com> wrote in message
news:Ox**************@TK2MSFTNGP14.phx.gbl...
Hi.
This is my problem. I'm filling a DataTable with data from my DB. The
problem is that none of the data is unique, not even combined. So I was
wondering if it is possible to add a unique column (AutoIncrement) to the
DataTable after (or before) I fill it with data?

Thanks,
Shawn

Nov 19 '05 #2

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

Similar topics

2
by: alan | last post by:
Hi Does primarykey property on the datatable object always need to be set in your code (for use with datarow.find) or should this be set automatically from your database tables primary key coz this...
0
by: Alan | last post by:
H When adding a new row to a datatables .row collection how do populate the primarykey field , ie SupplierId. Is there a way of retrieving the next available value automatically Thank Alan.
0
by: MuZZy | last post by:
Hi, I wonder if anybody could help me here: i'm trying to set a primary key on a table DataTable dt = new DataTable; FillTable(dt); dt.PrimaryKey = myDataColumn; , and in case if the...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
11
by: Geoff Jones | last post by:
Hi Can anybody help me with the following problem? I have a datasource i.e. some data, which I'm accessing via some VB. This I have done; with the help of you guys. However, the original data,...
10
by: Bernie Yaeger | last post by:
I have a need to add a primary key to a dataset/datatable. How can this be done using a standard oledb data provider? Tx for any help.
4
by: Lars E | last post by:
Hi all How can i set primarykey to a datatable. This datatable is in a dataset i get from a backend system. My datatable contains several fields, and i want to make the fields "c-custno1",...
0
by: Indra Bisen | last post by:
Hi, I want to determine column names of Primary Key Columns of a SQL Server Table. To do this I've found following example in MSDN under PrimaryKey property of DataTable. I've add some lines of...
2
by: canoewhiteh2o | last post by:
I am having trouble adding data columns to a disconnected database. I first load a datatable using: private DataTable dtMacros = new DataTable(); private ArrayList macro = new ArrayList();...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.