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

assigning primary key to more than one column

Sir,

if we want to assign a primary key to a single cloumn. below code is used.

objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary,
"PrimaryKey_Field")

if i want to assign primary to more than one column then what will be code.
Nov 21 '05 #1
3 1324
Hi,

The datatable's primarykey accepts an array of datacolumns. Link
shows an example.

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

Ken
------------------------
"gaffar" <Sa********@yahoo.co.in> wrote in message
news:eX****************@TK2MSFTNGP15.phx.gbl...
Sir,

if we want to assign a primary key to a single cloumn. below code is used.

objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary,
"PrimaryKey_Field")

if i want to assign primary to more than one column then what will be code.

Nov 21 '05 #2
Sir Can you help the same code in the Vb.net
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:u6**************@TK2MSFTNGP14.phx.gbl...
Hi,

The datatable's primarykey accepts an array of datacolumns. Link
shows an example.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatadatatableclassprimarykeytopic.asp
Ken
------------------------
"gaffar" <Sa********@yahoo.co.in> wrote in message
news:eX****************@TK2MSFTNGP15.phx.gbl...
Sir,

if we want to assign a primary key to a single cloumn. below code is used.
objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary,
"PrimaryKey_Field")

if i want to assign primary to more than one column then what will be code.

Nov 21 '05 #3
Hi,

Try something like this.
dsClient.Tables(0).PrimaryKey = New DataColumn()
{dsClient.Tables(0).Columns("FirstName"),
dsClient.Tables(0).Columns("LastName")}

Ken

---------------------------

"gaffar" <Sa********@yahoo.co.in> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Sir Can you help the same code in the Vb.net
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:u6**************@TK2MSFTNGP14.phx.gbl...
Hi,

The datatable's primarykey accepts an array of datacolumns. Link
shows an example.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatadatatableclassprimarykeytopic.asp
Ken
------------------------
"gaffar" <Sa********@yahoo.co.in> wrote in message
news:eX****************@TK2MSFTNGP15.phx.gbl...
Sir,

if we want to assign a primary key to a single cloumn. below code is used.
objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary,
"PrimaryKey_Field")

if i want to assign primary to more than one column then what will be code.


Nov 21 '05 #4

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

Similar topics

6
by: John Simmons | last post by:
How is it that even though I have the column "username" in my database set as a Primary key, using my PHP script to add new users to the database works without any errors even when signing up using...
6
by: cjm | last post by:
I need to group records and assign a setid to the group. I have a table with data that looks like this ColA ColB 94015 01065 94016 01065 94015 01085 94015 01086 33383 00912 32601 00912
17
by: Philip Yale | last post by:
I'm probably going to get shot down with thousands of reasons for this, but I've never really heard or read a convincing explanation, so here goes ... Clustered indexes are more efficient at...
4
by: Mavis Tilden | last post by:
Hi all, So I've been reading the newsgroups, and reading a few books trying to learn SQL and SQL Server 2000. The books tell me I need a Primary Key, and that every table should have one. I know...
3
by: mfyahya | last post by:
I have a table `books` with booktitle and authorname columns. In my applicatoin booktitle has unique values but authorname doesn't. ie an author can have many books but not the other way around. ...
11
by: Martin | last post by:
Hi, I understand you must first remove the constraint. The following bit does not work (where t is a DataTable). It gives a 'reference not set to an object' error ...
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,...
5
by: Phil Latio | last post by:
I have 2 virtually identical tables and wish to move data between them. Basically one table is called "live_table" and the other is named "suspended_table" and the only difference is that the...
4
by: newbtemple | last post by:
New to programming and got a question. I'm trying to add a primary key in vb.net to a table I made in SQL. The table in SQL does not have a primary key. I pull that table into my program and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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,...
0
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...

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.