|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SqlDataReader .NET 2.0 GetSchemaTable not returning AutoIncrementSSo 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 Show quote "Jaffa" wrote: > 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,
My mistake. I went back and checked with both OleDb and SQLClient and neither one supplies the AutoIncrement seed and step. Kerry Moorman Show quote "Jaffa" wrote: > But does that tell you the AutoIncrement seed and step? I have tried that and > I am not getting that information back.... > > "Kerry Moorman" wrote: > > > 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 > > > > > > "Jaffa" wrote: > > > > > 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 > > > But does that tell you the AutoIncrement seed and step? I have tried that and
I am not getting that information back.... Show quote "Kerry Moorman" wrote: > 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 > > > "Jaffa" wrote: > > > 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 > > 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 Show quote "Jaffa" <Ja***@discussions.microsoft.com> wrote in message news:990C810A-8832-459F-858B-A2DE3427A654@microsoft.com... > But does that tell you the AutoIncrement seed and step? I have tried that > and > I am not getting that information back.... > > "Kerry Moorman" wrote: > >> 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 >> >> >> "Jaffa" wrote: >> >> > 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 >> > |
|||||||||||||||||||||||