I need to copy records from tables in a database to another database with identical structure and table names and login parameters using ODBC for SYBASE 5.
I have 2 UniConnection, 2 ODBC Providers and 2 UniTable components on a form.
I set the UniConnection->Provider to ODBC on both connection components. Table1->Connection=UniConnection1 and Table2->Connection2=UniConnection2.
I use the code: UniConnection->Server = ODBC ALIAS name
with different names for the 2 components but when I use the code
UniConnection1->Server=aliasname1
UniConnection1->Connected=true
Table1->Open
UniConnection2->Server=aliasname2
UniConnection2->Connected=true
Table2->Open
The second connection is made to the first database and table instead of to the second.
If I delete one of the ODBC Provider components the same thing happens.
If I select a different database for the first one the same thing happens.
What am I doing wrong ?
ODBC copy between databases
Hello
I am using SYBASE 5 not Adaptive Server Enterprise so I cannot use ASE.
I have discovered the reason for this behaviour - SYBASE 5 ODBC specifies for each ODBC Data Source Name also a separate 'Database Name' which is not necessarily the same as the ODBC Data Source Name.
I assumed that the key name is the ODBC Data Source Name but in fact the second key name is the Database Name. If you create 2 ODBC entries with different ODBC Data Source Names but identical Database Names, then, despite setting UniConnection->Server = ODBC Data Source Name to be different for UniConnection1 and UniConnection2, the same database is opened in both cases.
In my case, for example:
ODBC Data Source 1 = A2ZMANAGER
Database Name 1 = A2ZMANAGERx
ODBC Data Source 2 = A2ZMANAGERDEMO
Database Name 2 = A2ZMANAGERx
UniConnection1->Server = "A2ZMANAGER";
UniConnection2->Server = "A2ZMANAGERDEMO";
Whichever database I open first, the same database is opened for the other connection.
The problem arose because when I rename ODBC entries I have only renamed the ODBC Data Source Names and not the Database Names so I had several entries with identical Database Names.
So, I have renamed the Database Names and the problem is solved - thank you.
I am using SYBASE 5 not Adaptive Server Enterprise so I cannot use ASE.
I have discovered the reason for this behaviour - SYBASE 5 ODBC specifies for each ODBC Data Source Name also a separate 'Database Name' which is not necessarily the same as the ODBC Data Source Name.
I assumed that the key name is the ODBC Data Source Name but in fact the second key name is the Database Name. If you create 2 ODBC entries with different ODBC Data Source Names but identical Database Names, then, despite setting UniConnection->Server = ODBC Data Source Name to be different for UniConnection1 and UniConnection2, the same database is opened in both cases.
In my case, for example:
ODBC Data Source 1 = A2ZMANAGER
Database Name 1 = A2ZMANAGERx
ODBC Data Source 2 = A2ZMANAGERDEMO
Database Name 2 = A2ZMANAGERx
UniConnection1->Server = "A2ZMANAGER";
UniConnection2->Server = "A2ZMANAGERDEMO";
Whichever database I open first, the same database is opened for the other connection.
The problem arose because when I rename ODBC entries I have only renamed the ODBC Data Source Names and not the Database Names so I had several entries with identical Database Names.
So, I have renamed the Database Names and the problem is solved - thank you.