问:添加主键 [英] Q: Adding a primary key

查看:56
本文介绍了问:添加主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有人可以帮我解决以下问题吗?我有一个数据源,即

一些数据,我正在通过一些VB访问。我已经这样做了;在你的帮助下你好吗?b $ b你们。但是,原始数据,以及我正在工作的数据集
with,没有主键列。我显然想添加一个。

最简单的方法是什么?


我的第一个想法是简单地添加一列,到目前为止我可以看到在数据集表的现有列的​​末尾将是

,然后向列中添加唯一的

值,即遍历表的每一行并在我创建的新列中添加一个

vaule。


有更简单或更有效的方法吗?


提前致谢


Geoff

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, and so the dataset I''m working
with, does not have a primary key column. I would obviously like to add one.
What is the easiest way to do this?

My first idea was to simply add a column, which as far as I can see will be
at the end of the existing columns of the dataset table, and then add unique
values to the column i.e. iterate through each row of the table and add a
vaule to the new column I have created.

Is there an easier or more efficient way of doing this?

Thanks in advance

Geoff

推荐答案

嗨Geoff,


是看看这里(我假设您知道如何使用该对象创建一个主键列



http://msdn.microsoft .com / library / de ... entcolumns.asp

我希望这有帮助吗?

Cor
Hi Geoff,

Yes have a look here (I assume you know how to create an primarykey column
using the object)

http://msdn.microsoft.com/library/de...entcolumns.asp

I hope this helps?

Cor
任何人都可以帮我解决以下问题吗?我有一个数据源,即一些数据,我正在通过一些VB访问。我已经这样做了;你们的
帮助。但是,原始数据,以及我正在使用的数据集,没有主键列。我显然想加上
一个。最简单的方法是什么?

我的第一个想法是简单地添加一个列,据我所知,
将位于数据集现有列的末尾表,然后将
唯一值添加到列中,即遍历表的每一行,并将
vaule添加到我创建的新列中。

是否更容易或更有效的方式吗?

提前致谢

Geoff
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, and so the dataset I''m working
with, does not have a primary key column. I would obviously like to add one. What is the easiest way to do this?

My first idea was to simply add a column, which as far as I can see will be at the end of the existing columns of the dataset table, and then add unique values to the column i.e. iterate through each row of the table and add a
vaule to the new column I have created.

Is there an easier or more efficient way of doing this?

Thanks in advance

Geoff



你好


你可以根据Cors链接添加一个Autoincrementing列。

然后将此列设置为主键。


Dim myColArray(0)As DataColumn

myColArray(0)= workTable.Columns(" MyAutoIncColumn")

workTable.PrimaryKey = myColArray


然后将数据输入数据表。自动增量柱将显示自动增量,因此不需要后续迭代。


hth

Richard
Hello

You would add an Autoincrementing column as per Cors link.
Then set this column as the primary key.

Dim myColArray(0) As DataColumn
myColArray(0) = workTable.Columns("MyAutoIncColumn")
workTable.PrimaryKey = myColArray

Then you feed your data into the datatable. The autoincrementing column will
obviously autoincrement such that no subsequent iteration is required.

hth
Richard


Hi Cor


使用这种技术,表中已存在的行是否已将

值添加到新列?


Geoff


" Cor Ligthert" <无********** @ planet.nl>在消息中写道

news:O
Hi Cor

Using this technique, would the rows already exisiting in the table have
values added to the new column?

Geoff

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:O


这篇关于问:添加主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆