Clive Morgan
8/15/2002 5:22:00 PM
Ran same OdbcCommandBuilder test against a SQLServer data
source and against a Caché data source. The Caché test
fails because of a call to SQLPrimaryKeysW with NO value
specified for the 'Schema/Owner' input parameter. The
SQLServer test succeeds because SQLPrimaryKeysW is NOT
called!!!
Example table was created in both databases using :-
create table user1.table1
(field1 varchar(10) primary key,
field2 varchar(10))
Test performed using following C# code :-
OdbcCN = new OdbcConnection(connectonString)
OdbcDA = new OdbcDataAdapter();
OdbcDA.SelectCommand = new OdbcCommand(
"select * from user1.table1", OdbcCN);
OdbcCB = new OdbcCommandBuilder(OdbcDA);
OdbcCN.Open();
TheCommand = OdbcCB.GetUpdateCommand
().CommandText.ToString();
The failure is caused by a call to SQLPrimaryKeysW
which values the TableName input parameter as "table1"
and values the SchemaName/OwnerName input parameter as
"" rather than as "user1".
As there is no table called table1 (it's user1.table1),
no Primary keys are returned to the OdbcCommandBuilder
objects. Hence the error.
I have run this test against SQLServer using the
SQLServer ODBC driver and against Caché using the Caché
ODBC driver. The call to SQLPrimaryKeysW is only made
when using the Caché ODBC data source.
Why is SQLPrimaryKeysW being called and why is there no
value specified in the SchemaName input parameter?
The ODBC trace log shows that SQLColAttributeW is called
when connected to the SQLServer data source and that
SQLColAttributesW is called when connected to the
Caché ODBC data source. However detailed analysis has
shown the the same information was provided including
the vital information on which field in NULLABLE.
The test against the SQLServer ODBC data source does
not fail showing that there is no need to call
SQLPrimaryKeysW.
Is this a feature or a bug of the ODBC.NET provider.
It currently means that we are unable to use multiple
schema in the same catalog!!!! The only alternative is
NOT to use the OdbcCommandBuilder object.