Page 1 of 1

ODBC copy between databases

Posted: Tue 09 Aug 2011 17:48
by RichTat
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 ?

Posted: Wed 10 Aug 2011 08:34
by AlexP
Hello,

I cannot reproduce the problem.
If you setup DSN correctly and if you specify different values in the Server property, you connect to the database specified in DSN.
Please check the settings of your DSN, also you can try to use the ASE provider that does not require creating DSN.

Posted: Wed 10 Aug 2011 10:56
by RichTat
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.

Posted: Thu 11 Aug 2011 10:53
by AlexP
Hello,

Glad to see that the problem was solved. If you have any other questions, feel free to contact us.