SqlDataReader .NET 2.0 GetSchemaTable not returning AutoIncrementS

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

So I have this:

SqlDataReader rdr = ExecuteDataReader(connection, Command.Text, "Select *
from myTableName");

DataTable table = rdr.GetSchemaTable();

This is working great and telling me all the defined columns within the
myTableName, except if the column is an identity and autoincremented it is
not returning the right AutoIncrementSeed or AutoIncrementStep. Am I doing
something wrong or does GetSchemaTable() not return the AutoIncrementStep.

Or is there another way to find out what the field/column's
AutoIncrementStep, AutoIncrementSeed is?

Thanks,
Matt
 
Matt,

In .Net 1.1 I get schema info like this, after setting up the command
object's connection and commandtext:

rdr = cmd.ExecuteReader(CommandBehavior.SchemaOnly Or CommandBehavior.KeyInfo)

Kerry Moorman
 
Matt,

My mistake. I went back and checked with both OleDb and SQLClient and
neither one supplies the AutoIncrement seed and step.

Kerry Moorman
 
But does that tell you the AutoIncrement seed and step? I have tried that and
I am not getting that information back....
 
Are you using .NET 2.0 or 1.1?

If you're in .NET 2.0, you can use SqlConnection.GetSchema("Indexes", new
string[] { null, null, "tablename" } );

This will give you all the indexes for the given table, and I believe there
will be primary key info along with autoincrement info in there.

Robert
 
Back
Top