Excel-VBA to SQLite3 through ODBC Driver: primary database + attached database - vba

I'm trying to connect from Excel-VBA to SQLite3 database through ODBC (Windows 10 x64).
I use Christian Werner's SQLite ODBC driver v 0.9999 (http://www.ch-werner.de/sqliteodbc) - as manual says I've installed both install both 32 and 64Bit versions of the driver.
Connecting to one database is ok:
ConnectionString = "DRIVER=SQLite3 ODBC Driver;Database=c:\first.db;"
Connecting to 2 databases (SQLite provides ability to connect to primary database + attached database) is also ok:
ConnectionString = "DRIVER=SQLite3 ODBC Driver;Database=c:\first.db;Attach=c:\second.db;"
but looks like VBA don't see tables from attached database - the following query fails:
SELECT * FROM [second].[table_name_in_second_db];
Does that SQLite ODBC driver supports attach database in connection string?
Or maybe I use incorrect syntax?

You don't handle attachments thru the connection. The primary database is handled in the connection properties. Once you have a valid connection you're essentially using sqlite engine. (the driver is a wrapper for sqlite.dll) Therefore you can attach databases as sql statements.
cn.execute "attach database 'C:\filename.db' as db"

Related

Configuration file in Netezza

Is there a configuration file in Netezza like tnsnames.ora in Oracle which contains database names and their connect string names?
If so, what is the default location of the file?
I'm using Informatica PowerCenter to load to target Netezza table. I want to know the Database details of the connect string Informatica uses to connect with Netezza DB. In Oracle, I could have got the informatica from tns file.
Netezza doesn't have an equivalent to Oracle TNSNames.
ODBC Connection String Example:
Driver={NetezzaSQL};servername=myServerAddress;port=myPortNumber;
database=myDataBase;username=myUsername;password=myPassword;
ODBC ConnectionStrings.com
ODBC Configuration IBM
JDBC Configuration IBM
You can check the dsn entry (connect string name in Informatica connection) in the odbc.ini file in the LD_LIBRARY_PATH which is defined at the time of Netezza ODBC driver installation
In PowerCenter, a developer can check the connection details only if a dedicated connector is used. For ODBC, the only information available in Workflow Manager is the name of ODBC. The details can be checked in ODBC definition on the server.
A small addition to #Marciejg:
We have only a few odbc connections compared to powercenter connections. Each odbc points to the ‘system’ database and in the powercenter connection pointing to a specific database on that server, we run a ‘set current_catalog PROD_EDW’ in the pre sql. That way things are mostly visible and manageable in powercenter, and the odbc only points to the server.
And slightly off topic: the pre sql has additional ‘set CLIENT_*_NAME’ statements that enters the powercenter workflow/session etc dynamically based on powercenter build in variables (they are named $PMWorkflowname and similar)
That way we can trace back to the powercenter code immediately from a planfile, the pg.log or most interestingly, the HISTDB
Follow these links if you want to play with it:
- https://www.ibm.com/support/knowledgecenter/SSULQD_7.2.1/com.ibm.nz.dbu.doc/r_dbuser_set.html
and
http://dwhlaureate.blogspot.dk/2012/09/built-in-variables-in-informatica.html

Error using Sybase IQ proxy table

I have a use case that requires me to make a join on a table t1 from Sybase ASE and table t2 from Sybase IQ . I am trying to achieve this by creating a proxy_table on Sybase IQ as follows:
create server SYB1 class 'ASAODBC' using
Driver=libsyb64.so;Server=hostname;Port=portnum;PacketSize=16384;
EnableServerPacketSize=0'
(I even tried above with 'ASEODBC' and 'ODBC' classes)
create external login XYZ to SYB1 remote login 'SYBASEASEusername'
identified by SYBASEASEpwd'
create existing table 'proxy_table_name' at 'SYB1.dbname.owner.tablename'
On firing above sqls I get:
[Sybase][ODBC Driver][Sybase IQ] Unable to connect to 'SYB1': [Sybase][ODBC Driver]
[SQL Anywhere] Unable to connect ; server definition is circular
I have entry for the above mentioned Sybase ASE host in interfaces file and I tried to create the server by specifying the server name itself but it failed nevertheless.
Any help appreciated.
That error occurs when you attempt to connect to a remote server that maps to the local database. That's not possible in Sybase IQ. Check if the ODBC is pointing to the correct server (in your case should be the ASE server).
Your proxy server is using class 'ASAODBC' but since you're connecting to an ASE server, it should be 'ASEODBC'. As aF. said, you also need to make sure your connection string is pointing at the ASE server, not the IQ server.
Full disclosure: I work for SAP in SAP SQL Anywhere engineering. SQL Anywhere is the execution engine for SAP IQ (formerly Sybase IQ).

VBSCRIPT connection to Oracle failing due to driver

I am using a vbscript which connects to SQL.
My connection String look like
connectionString = "DRIVER={Microsoft ODBC for Oracle};SERVER=convcsd;User Id=sysman;Password=csaadmin;"
Set connection = CreateObject("ADODB.Connection")
It is working on one server but not on another. it gives an error :
The oracle(tm) and networking components were not found. These
components are supplied by oracle corporation..
You will be unable to use this driver until these components have been
installed.
Please let me know how to add ODBC driver. I researched but not able to get through.
SQL Plus is an Oracle client yes but that is not enough to be able to use your script. You need an ODBC driver and prefable an OleDb driver (is faster) for Oracle on each pc you're going to use your script.
Compare the ODBC drivers between two 2 pc's with the Microsoft ODBC administrator (type ODBC in your startmenu searchwindow) and you will notice the difference. Use your Oracle installpackage and check the option to install the OleDb driver.
There is a Microsoft and an Oracle version, again it is best to use the Oracle driver. The connection string for Oracle OleDb is
Provider=OraOLEDB.Oracle;User ID=<user name>;Password=<password>;Data Source=<data source>

ODBC Linked server in sql 2005 doesn’t work from remote box

I have a dev workstation with sql 2005 installed and in it I created a linked server to a odbc connection to a clarion database. I can run select statements against it inside sql Mgt studio. When I take a second workstation and connect to the sql on the first box using sql mgt studio, then try the exact same query I get
OLE DB provider "MSDASQL" for linked server "liveclarion" returned message "[SoftVelocity Inc.][TopSpeed ODBC Driver][ISAM]ISAM Table Not Found".
Any thoughts? It appears to have the same functionality on a second sql server. No remote sql mgt studio connect success in queries against my linked ODBC clarion DB.
All done with windows authentication and the same AD user.
The error returned by the ODBC driver is "SAM table not found".
So I'm assuming you have a table called SAM - presumably in a table called Sam.Tps?
I'm wondering if you need to set a path to that file - ie if there's some difference in path or file name validity between your two tests. One assumes not, but I'd look in that direction first.

How do you setup a linked server to an Oracle database on SQL 2000/2005?

I am able to create and execute a DTS package that copies tables from a remote Oracle database to a local SQL server, but want to setup the connection to the Oracle database as a linked server.
The DTS package currently uses the Microsoft OLE DB Provider for Oracle with the following properties:
Data Source: SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.3.42)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=acc)));uid=*UserName*;pwd=*UserPassword*;
Password: UserPassword
User ID: UserName
Allow saving password: true
How do I go about setting a linked server to an Oracle database using the data source defined above?
I was able to setup a linked server to a remote Oracle database, which ended up being a multi-step process:
Install Oracle ODBC drivers on SQL Server.
Create System DSN to Oracle database on SQL Server.
Create linked server on SQL server using System DSN.
Step 1: Install Oracle ODBC drivers on server
a. Download the necessary Oracle Instant Client packages: Basic, ODBC, and SQL*Plus (optional)
b. Unzip the packages to a local directory on the SQL server, typically C:\Oracle. This should result in a [directory] like C:\Oracle\instantclient_10_2, which will be the value of [directory] referenced in the rest of this answer.
c. Create a text file named tnsnames.ora within the instant client [directory] that contains the following:
OracleTnsName =
(
DESCRIPTION=
(
ADDRESS = (PROTOCOL=TCP)(HOST=10.1.3.42)(PORT=1521)
)
(
CONNECT_DATA = (SERVICE_NAME=acc)
)
)
Note: Actual HOST, PORT, and SERVICE_NAME will vary based on Oracle server you are establishing a connection to. This information can often be found using the Oracle network client tools under the listeners.
The OracleTnsName can be any name you want to assign to the Oracle data source, and will be used when setting up the system DSN. You can also use the syntax above to define multiple TNS names in the same tnsnames.ora file if desired.
d. Add the [directory] to the system PATH environment variable.
e. Create a new system environment variable named TNS_Admin that has a value of [directory]
f. Execute the [directory]\odbc_install.exe utility to install the Oracle ODBC drivers.
g. It is recommended that you reboot the SQL server, but may not be necessary. Also, you may want to grant security permissions to this directory for the SQL server and SQL agent user identities.
Step 2: Create a System DNS that uses the Oracle ODBC driver
a. Open the ODBC Data Source Administrator tool. [ Administrative Tools --> Data Sources (ODBC) ]
b. Select the System DSN tab and then select the Add button.
c. In the drivers list, select Oracle in instantclient {version}. (e.g. 'Oracle in instantclient 10_2') and then select Finish button.
d. Specify the following:
Data Source Name: {System DSN Name}
Description: {leave blank/empty}
TNS Service Name: should have the OracleTnsName you defined in the tnsnames.ora file listed, select it as the value.
User ID: {Oracle user name}
e. Select Test Connection button. You should be prompted to provide the {Oracle user password}. If all goes well the test will succeed.
Step 3: Create linked server in SQL to the Oracle database
Open a query window in SQL server and execute the following:
EXEC sp_addlinkedserver
#server = '{Linked Server Name}'
,#srvproduct = '{System DSN Name}'
,#provider = 'MSDASQL'
,#datasrc = '{System DSN Name}'
EXEC sp_addlinkedsrvlogin
#rmtsrvname = '{Linked Server Name}'
,#useself = 'False'
,#locallogin = NULL
,#rmtuser = '{Oracle User Name}'
,#rmtpassword = '{Oracle User Password}'
Note: The {Linked Server Name} can be anything you want to use when referencing the Oracle server, but the {System DNS Name} must match the name of the system DSN you created previously.
The {Oracle User Name} should be the same as the User ID used by the system DSN, and the {Oracle User Password} should be the same as you used to successfully test the ODBC connection. See KB 280106 for information on troubleshooting Oracle linked server issues.
Querying the Oracle linked server
You may use OPENQUERY to execute pass-through queries on the Oracle linked server, but be aware that for very large recordsets you may receive a ORA-01652 error message if you specify a ORDER BY clause in the pass-through query. Moving the ORDER BY clause from the pass-through query to the outer select statement solved this issue for me.
I had the same problem. I was on the phone with Microsoft for hours, and they did not have a solution. None of those "connection timeout" settings helped me.
To resolve it, I created a DTS job that runs a proc which only updates the time on one row, in one column, every two minutes. Then I setup a replication between SQL Server and Oracle, scheduled to replicate that single cell change, from SQL to Oracle, every 3 minutes. It keeps the connection alive!