Home All Groups Group Topic Archive Search About

SqlDataReader .NET 2.0 GetSchemaTable not returning AutoIncrementS

Author
17 Apr 2006 4:58 PM
Jaffa
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

Author
17 Apr 2006 6:20 PM
Kerry Moorman
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
>
Author
17 Apr 2006 8:31 PM
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


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
> > >
Author
17 Apr 2006 8:31 PM
Jaffa
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
> >
Author
17 Apr 2006 8:41 PM
Robert Simpson
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
>> >

AddThis Social Bookmark Button