Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 11th, 2003, 07:09 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default Creating a PrimaryKey for a DataTable


I'm new to C#. In VB.NET, you create a primary key for a data table in the following fashion:
objTable.PrimaryKey = new DataColumn() {objTable.Columns("ID")}
Does anybody know the C# equivalent?


Brian Mains
Old December 13th, 2003, 03:49 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik

if u r using DataSet thi sis the code.

DataSet1.[TableName].PrimaryKey = new System.Data.DataColumn[] {DataSet1.TableName.Columns[Coulomn_Number]};

Hovik Melkomian.
Old May 31st, 2010, 12:30 AM
Registered User
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating a PrimaryKey for a DataTable

please use this for c#

objTable.PrimaryKey = new DataColumn() {objTable.Columns("ID")}

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the value from the DataTable column Dmitriy Pro VB 6 4 March 30th, 2010 08:58 AM
Datatable Limno .NET Framework 1.x 0 May 28th, 2008 02:37 PM
Creating DataSet/DataTable from XML hhmoeller XML 4 March 22nd, 2006 10:41 AM
Updating datatable Nikos General .NET 1 November 4th, 2004 04:43 PM
PrimaryKey problem melvik ADO.NET 2 August 20th, 2003 12:41 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.