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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top