Inspecting the ADO with c#

  • Thread starter Thread starter mardukes
  • Start date Start date
M

mardukes

the database is SQL2000

cmd.CommandText = "SELECT TOP 1 * FROM " + target.Text;
conn.Open();
tableReader = cmd.ExecuteReader();
schemaTable = tableReader.GetSchemaTable();

where k is the primary key field:

schemaTable.Rows[k]["IsKey"]

does not show as true while

schemaTable.Rows[k]["AllowDBNull"]

does show as not nullable (and all the other schema values I've used
are also correct)

anyone know why?
 
the solution is (hope I remembered correctly):

tableReader = cmd.ExecuteReader(CommandBehavior.KeyInfo);

the default which doesn't look up the key info is as such because the
process is expensive
 
Back
Top