none
Identity Column in SQL Server 2005 and VB.NET 2005 RRS feed

  • Question

  •  

    I have the following line in my .NET code to return me a schema table.
     Dim SQL As SqlCommand = pda.SelectCommand
     Dim rdr As SqlDataReader
     rdr = SQL.ExecuteReader(CommandBehavior.SchemaOnly & CommandBehavior.SingleResult)

    This code has been working fine for SQL 2000 where for a column that has a identity column and auto increment on it will return true for isidentity.  When we move to 2005 and set the compatability to 2005 this suddenly return false.  If we set the compatibility to 2000 then it return true as expected.  Why is it return false if we set compatibility to 2005.

    Tuesday, March 18, 2008 8:03 PM

All replies

  • Could you explain in more detail how you are geting schema table?

     

    For example, what is the SQL.CommandText here?  What is pda?

     

    If you can print out SQL.CommandText it will help me understand what you are trying to do.

     

    Also, I found these ExecuteReader options are contradictory:

     

    SQL.ExecuteReader(CommandBehavior.SchemaOnly & CommandBehavior.SingleResult)

     

    CommandBehavior.SchemaOnly means only send schema information and do not send ANY rows.  It sends SET FMT ONLY to the server which tells the server to skip sending rows.

     

    CommandBehavior.SingleResult means you only expect a single resultset.

     

    Specifying CommandBehavior.SingleResult turns off CommandBehavior.SchemaOnly.

     

     

     

    Tuesday, March 25, 2008 1:55 AM