SqlException: Invalid object name 'sys.table_types' in SqlConnection.GetSchema() after installing VS

S

Samuel R. Neff

I recently installed VS 2008 and .NET 3.5 and am now getting an error
executing a .NET 2.0 application. This application has not been
opened in VS2008 or converted to use .NET 3.5 and has not even been
recompiled since VS2008 was installed.

Seems like now the SqlConnection code is assuming by data source is a
MS SQL 2008 database which is not the case, it's a MSSQL 2005
database.

It's a command line application and does not have an app.config file.
I guess it's picking up the new runtime which is not smart enough to
figure out which version of MSSQL it's connecting to. Is that
correct?

So I guess i have a few options to fix it..
1. add an app.config to specify which runtime to use..
2. change code to specifically ignore the bad schema collection not
supported by sql 2005
3. somehow specify that connection is mssql 2005??

So any suggestions? Is the third option even possible? if so how? Any
other options?

Thanks,

Sam

select @@version

Microsoft SQL Server 2005 - 9.00.2050.00 (Intel X86) Feb 13 2007
23:02:48 Copyright (c) 1988-2005 Microsoft Corporation Standard
Edition on Windows NT 5.2 (Build 3790: Service Pack 1)


The offending code is..


DbProviderFactory dbf =
DbProviderFactories.GetFactory(cs.ProviderName);
using(DbConnection cnn = dbf.CreateConnection())
{
cnn.ConnectionString = cs.ConnectionString;
cnn.Open();

DataSet data = new DataSet("Schema");
DataTable meta = cnn.GetSchema();

foreach(DataRow row in meta.Rows)
{
// error here when
// row["CollectionName"] =="StructuredTypeMembers"

data.Tables.Add(cnn.GetSchema((string)row["CollectionName"]));
}



The full error is:

Unhandled Exception: System.InvalidOperationException: Unable to build
the 'StructuredTypeMembers' collection because execution of the SQL
query failed. See the inner exception for details.

--->

System.Data.SqlClient.SqlException: Invalid object name
'sys.table_types'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException
exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString)
at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async)
at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result)
at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method)
at
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at
System.Data.ProviderBase.DbMetaDataFactory.ExecuteCommand(DataRow
requestedCollectionRow, String[] restrictions, DbConnection
connection)
--- End of inner exception stack trace ---
at
System.Data.ProviderBase.DbMetaDataFactory.ExecuteCommand(DataRow
requestedCollectionRow, String[] restrictions, DbConnection
connection)
at
System.Data.ProviderBase.DbMetaDataFactory.GetSchema(DbConnection
connection, String collectionName, String[] restrictions)
at
System.Data.ProviderBase.DbConnectionInternal.GetSchema(DbConnectionFactory
factory, DbConnectionPoolGroup poolGroup, DbConnection
outerConnection, String collectionName, String[] restrictions)
at System.Data.SqlClient.SqlConnection.GetSchema(String
collectionName, String[] restrictionValues)
at System.Data.SqlClient.SqlConnection.GetSchema(String
collectionName)
at Generators.MsSqlSource.MsSqlReader.ReadSchema(String
connectionName) in
c:\Projects\src\Generators\Generators.MsSqlSource\MsSqlReader.cs:line
437
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You do not have a config file?
where do you store your connection string?

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Samuel R. Neff said:
I recently installed VS 2008 and .NET 3.5 and am now getting an error
executing a .NET 2.0 application. This application has not been
opened in VS2008 or converted to use .NET 3.5 and has not even been
recompiled since VS2008 was installed.

Seems like now the SqlConnection code is assuming by data source is a
MS SQL 2008 database which is not the case, it's a MSSQL 2005
database.

It's a command line application and does not have an app.config file.
I guess it's picking up the new runtime which is not smart enough to
figure out which version of MSSQL it's connecting to. Is that
correct?

So I guess i have a few options to fix it..
1. add an app.config to specify which runtime to use..
2. change code to specifically ignore the bad schema collection not
supported by sql 2005
3. somehow specify that connection is mssql 2005??

So any suggestions? Is the third option even possible? if so how? Any
other options?

Thanks,

Sam

select @@version

Microsoft SQL Server 2005 - 9.00.2050.00 (Intel X86) Feb 13 2007
23:02:48 Copyright (c) 1988-2005 Microsoft Corporation Standard
Edition on Windows NT 5.2 (Build 3790: Service Pack 1)


The offending code is..


DbProviderFactory dbf =
DbProviderFactories.GetFactory(cs.ProviderName);
using(DbConnection cnn = dbf.CreateConnection())
{
cnn.ConnectionString = cs.ConnectionString;
cnn.Open();

DataSet data = new DataSet("Schema");
DataTable meta = cnn.GetSchema();

foreach(DataRow row in meta.Rows)
{
// error here when
// row["CollectionName"] =="StructuredTypeMembers"

data.Tables.Add(cnn.GetSchema((string)row["CollectionName"]));
}



The full error is:

Unhandled Exception: System.InvalidOperationException: Unable to build
the 'StructuredTypeMembers' collection because execution of the SQL
query failed. See the inner exception for details.

--->

System.Data.SqlClient.SqlException: Invalid object name
'sys.table_types'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException
exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString)
at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async)
at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result)
at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method)
at
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at
System.Data.ProviderBase.DbMetaDataFactory.ExecuteCommand(DataRow
requestedCollectionRow, String[] restrictions, DbConnection
connection)
--- End of inner exception stack trace ---
at
System.Data.ProviderBase.DbMetaDataFactory.ExecuteCommand(DataRow
requestedCollectionRow, String[] restrictions, DbConnection
connection)
at
System.Data.ProviderBase.DbMetaDataFactory.GetSchema(DbConnection
connection, String collectionName, String[] restrictions)
at
System.Data.ProviderBase.DbConnectionInternal.GetSchema(DbConnectionFactory
factory, DbConnectionPoolGroup poolGroup, DbConnection
outerConnection, String collectionName, String[] restrictions)
at System.Data.SqlClient.SqlConnection.GetSchema(String
collectionName, String[] restrictionValues)
at System.Data.SqlClient.SqlConnection.GetSchema(String
collectionName)
at Generators.MsSqlSource.MsSqlReader.ReadSchema(String
connectionName) in
c:\Projects\src\Generators\Generators.MsSqlSource\MsSqlReader.cs:line
437


------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
 
S

Samuel R. Neff

I have a separate config file which is shared across multiple
executables and in a common location. It's not a standard application
config file.

Sam
 

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

Top