How to add Primary key in DataSet

Answer Posted / kamalakannan.a

If we use c#

DataTable dt=new DataTable();

DataColumn Dc1 = new DataColumn("No", Type.GetType
("System.Int32"));

dt.Columns.Add(Dc1);

//Set Primary key
DataColumn[] dc = new DataColumn[1];
dc[0] = dt.Columns["No"];
dt.PrimaryKey = dc;

Kamal..

Is This Answer Correct ?    34 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is method to get XML and schema from Dataset? getXML() and get Schema ()

547


How to add a check box or a dropdown list to a column in a datagrid?

544


What is microsoft ado?

521


How do you find the count of records in a dataset?

486


Does sqlclient and oledb class share the same functionality?

542






Define the data provider classes that is supported by ado.net?

525


What are the uses of Stored Procedure?

567


What is the difference between typed and untyped dataset?

514


What are the disadvantages of using datalist?

519


What is a column variable?

507


Can we do database operations without using any of the ado.net objects?

539


What is ole in vb?

518


What are advantages of microsoft-provided data provider classes in ado.net?

554


What is oledb connection?

515


What are three methods for displaying data in a syncfusion datagrid

619