Hi,
There are more then one ways to fetch the schema of the table. But in your
case it seems that you want to get the Primary key, column Names, Table Names
also. So the code given below best suits your requirements.
The code is written in C#.
SqlConnection sqlConnect = new SqlConnection();
sqlConnect.ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings.Get("CONN_STR");
sqlConnect.Open();
DataSet dtEmployee = new DataSet();
SqlCommand cmdEmployee = new SqlCommand("select * from
Employees",sqlConnect);
SqlDataAdapter dtaNorthwind = new SqlDataAdapter(cmdEmployee);
dtaNorthwind.FillSchema(dtEmployee,System.Data.SchemaType.Mapped,"Employee");
You can see in the immediate window the following results:
?dtEmployee.Tables[0].PrimaryKey[0].ColumnName
"EmployeeID"
?dtEmployee.Tables[0].TableName
"Employee"
?dtEmployee.Tables[0].Columns[0].ColumnName
"EmployeeID"
The fillSchema Method is used in the above e.g. with SchemaType.Mapped.
There are other ways also to fetch the schema, but the above method is the
best fit for your requirements.
Thanks and Regards,

Signature
Piyush Thakuria
Technical Lead
> It appears that the DA's Fill method does not grab the schema in situations
> like this:
[quoted text clipped - 14 lines]
> identifiers, both column names and table names? What's the conventional way
> of doing this?