hi frds,

I want to return primary key of a table. For that I use this code, but it is unable to access the primary key and show the error
" null refrence exception "

My code is --

Private void GetPrimaryKeys ( DataTable myTable ) {
   // create the array for the columns.
   DataColumn [ ] colKeys = myTable.PrimaryKey;
   // get the number of elements in the array.
   Response.Write ( "Column Count: " + colKeys.Length );

   for ( int i = 0; i < colKeys.Length; i++ ) {
      Response.Write ( colKeys [ ].ColumnName + 
         colKeys [ ].DataType );
   }

plz give your idea.
thanks in advance.....

You pass null DataTable variable!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.