Specify a default driver for ODBC - vb6

I have a legacy VB6 app which builds a DSN based on a parameter in a config file. The parameter is an ODBC connection, and the connection has a name (DSN-NAME) which maps a server (DBSERVER) to a driver ("SQL Server Native Client").
Generally, it builds a DSN like this:
DSN=DSN-NAME;User=foo;Password=bar
If I specify a hostname in the file, it builds a connection string which says
DSN=DBSERVER;User=foo;Password=bar
The error message reported is:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
This suggests to me that there is perhaps a way of specifying a default driver, which may mean I can specify just the server name in the config file, and not need to create the ODBC connection.
(I am aware these can be created automatically; this is just to simply installation, and to satisfy my curiosity).
How do you specify a default driver? If I can set the default driver to SQL Server Native Client, can I then say DSN=DBSERVER and connect?
Edit: the point was to try and do this without changing the connection string. All the research suggested this isn't actually possible, but he wording of the dialog suggested it might be.

I had the same problem and fixed it by using the 32-bit ODBC admin to create a 32-bit DSN rather than the 64-bit admin in Administrative Tools which only creates 64-bit DSN which don't work.
The 32-bit ODBC Manager is located at C:\Windows\SysWOW64\odbcad32.exe
See this article "Data source name not found and no default driver specified" on Corey Gilmore's blog.

To specify a default driver, use DRIVER= in the connection string:
DRIVER=driver name here;DATABASE=mydb;USER=foo;PASSWORD=bar
The driver name is the name that appears in the Control Panel ODBC config tool for each driver. Note you will need to supply the info which would normally come from the DSN, in this case the database name.

You can achieve what you want by appending ";SERVER=dbserver" to your connection string.
There is already a server specified in your DSN, but the SERVER keyword in your connectionstring will override that.
http://msdn.microsoft.com/en-us/library/ms715433(VS.85).aspx

Use a DSN-less connection string...it can be created 'on the fly' to exactly suite your purposes....no piddling with odbcad32.cpl or reg/ini files to control/configure a dsn required.
see http://support.microsoft.com/kb/147875
for details

Related

Export Database connection to Oracle Developer

I have a database Connection established in odbcad and Microsoft Access (aswell as working in Excel) via ODBC and want to also get it working in Oracle SQL developer.
It is a Windows SQL Server as far as i know and I have tried several Settings, of which None works. I have also installed Driver for ODBC. I would like to Import Settings into SQL developer as applied in MS Access, is there any possibility?
No, SQL Developer is a Java application and uses a JDBC driver.
But if you look at the odbc properties for your connection, those should largely translate to what you need to define a basic connection.
Oracle:
Server name or IP address of the DB, port # for the listener, and the name of the SID or Service, plus a valid username and password is all you need to connect to Oracle.
What error do you get when you try to connect?
Show us what you're trying.
Update:
You're trying to connect to SQL Server but you're getting"
Native SSPI library not loaded
You're trying to use OS Authentication for your connection. For this to work with the jTDS driver, you need to copy a DLL file named ntlmauth.dll (which is for NT authentication) under the jtds-x.x.x-dist\x86\SSO\ or jtds-x.x.x-dist\x64\SSO\, to any directories in the PATH environment.
Please update your question such that's it's clear you're connecting to SQL Server and share the error message so others can find it.
I imagine this question is a duplicate of many previous iterations of the same challenge.

how to set package per application with odbconf for ibm i access odbc driver

I would like to set IBM i Access odbc with command line on Windows 7 Enterprise 32-bit.
Almost configuration can be set with odbcconf command, referencing to a following site.
IBM Knowledge Center: Connection string keywords - Package properties
But I can't find properties for custom package setting per application.
Is there the way to set custom package per application with odbcconf or other command line tools?
You try make file dsn for IBM i Access odbc.
And this file dsn open Text Editor.
The Parameter in file dsn is to be able to use.
I tried this way informix and success to add dsn by odbcconf.
Maybe, other database is same.

Odbc connection not working if not defined as DSN entry

I have a problem with installing ODBC driver under Windows (7, 64bit) to connect to Oracle database. They kind of work - I mean I can define a DSN entry and open connection using "DSN=foobar" connection string but I can't use something more generic like passing full connection string to OdbcConnection or basing it on tnsnames.ora file. In both cases I get
"Data source name not found and no default driver specified"
What client software are you using? The answer is probably going to be, use ADO

Configuring IBM DB2 ODBC - Changing the Host IP / Alias already exists

I've created an IBM ODBC connection to my server via Microsoft's own ODBC Administrator. After initially finding difficulties on where to put in the IP Address (otherwise, the ODBC uses my local database server), it finally managed to connect to my server PC successfully.
During this process, however, I did not put in a Database Alias, as I did not know what it means, nor what it is for. The ODBC still works fine.
The server, however, changed its IP Address. I don't know how or why it does that, and how to stop it, but now my previously working ODBC is now unable to connect, saying it gave an error message at 192.168.1.127, the server's previous IP Address.
I tried, and failed, to find out how to change the Host IP via the ODBC configuration.
In frustration, I deleted the ODBC connection, created a new one under System DSN, etc., etc., but upon clicking finish, it says the alias URCDB already exists.
How can I solve these problems?
Note:
URCDB is the name of my database. In both occasions, I did not put
anything in the alias field.
There are two URCDBs during the ODBC creation process. One was for
the local test database I used to have on my PC (deleted), the other,
I guess, was the left over from the recently deleted ODBC to my
Server.
You have two options:
1. Create a DSN with different alias.
When creating DSN give the original database name in database name filed and in alias field provide different name other than origina database name.
uncatalog the database name using the below command
go to run --> type db2cmd
db2 uncatalog database database name
now open ODBC create the DSN with giving DSN name and alias name as original database name
Most likely your server has DHCP enabled whereas servers shoud have a static IP address. Hope this helps. DHCP addresses are usually consistent but depending on what level network protocols are in place, the can and will likely change at some point.

jdbc using sqlnet.ora

I have a program that wants to make a connection to an oracle database on our network. This program is written in java and has to use jdbc. Our PC's are setup to use sqlnet.ora files to determine the order of how to resolve. All our PC's first check ldap (which the ldap file is on all these PC's pointing to the ldap server) and then secondly to use tnsnames.ora file, but this file is empty now so basically I want to use ldap, but do it via sqlnet.ora. Any ideas what the connection would look like for the url parameter?
From the JDBC Developer's Guide
The oracle.net.tns_admin system property must be set to the location of the tnsnames.ora file so that the JDBC Thin driver can locate the tnsnames.ora file. For example:
System.setProperty("oracle.net.tns_admin", "c:\\Temp");
String url = "jdbc:oracle:thin:#tns_entry";
DriverManager.getConnection(url, ...);
Because of the system property, the thin driver is able to locate the tnsnames.ora file and thus can resolve the TNS name specified in the URL. Because the thin driver is usually intended to work without an Oracle client installation, this is not enabled by default.
As far as I remember, you only need tnsnames.ora, you don't need an Oracle client when using the thin driver even when specifying a TNS name.
If your program does not allow setting system properties you have two options:
Specify it when starting your program java -Doracle.net.tns_admin=c:/foobar ...
Set an environment variable JAVA_TOOLS_OPTIONS that contains -Doracle.net.tns_admin=c:/foobar. That will then be picked up by any Java program automtically
From the Oracle JDBC FAQ
jdbc:oracle:oci:#<<TNS alias>>
where <<TNS alias>> is the LDAP entry that you would use if you were connecting via, say, SQL*Plus

Resources