ODBC driver connectivity issue

S

SRK

Hi,
I am trying to use ODBC on Unix platform. I have installed unixODBC
driver manager and mysql connector. When I try to use through command
line, unixODBC driver manager works fine, but when I write a code in C
and try to run, it gives me connection error -

[unixODBC][Driver Manager]Data source name not found, and no default
driver specified


I have my .odbc.ini file in my home directory and I have even set
ODBCINI pointing to the .odbc.ini file, but still I am getting this
error.


Will greatly appriciate any reply on the same.


Thanks
Shiv
 
S

spinoza1111

Hi,
I am trying to use ODBC on Unix platform. I have installed unixODBC
driver manager and mysql connector. When I try to use through command
line, unixODBC driver manager works fine, but when I write a code in C
and try to run, it gives me connection error -

[unixODBC][Driver Manager]Data source name not found, and no default
driver specified

I have my .odbc.ini file in my home directory and I have even set
ODBCINI pointing to the .odbc.ini file, but still I am getting this
error.

Will greatly appriciate any reply on the same.

Thanks
Shiv

Let's see. The connection error is from unixODBC, therefore you have
unixODBC installed properly to run in C. Let's assume this is OK.

I'd check to see what's being passed as the data source name.

If you like, post the code.
 
S

SRK

Hi,
I am trying to use ODBC on Unix platform. I have installed unixODBC
driver manager and mysql connector. When I try to use through command
line, unixODBC driver manager works fine, but when I write a code in C
and try to run, it gives me connection error -
[unixODBC][Driver Manager]Data source name not found, and no default
driver specified
I have my .odbc.ini file in my home directory and I have even set
ODBCINI pointing to the .odbc.ini file, but still I am getting this
error.
Will greatly appriciate any reply on the same.
Thanks
Shiv

Let's see. The connection error is from unixODBC, therefore you have
unixODBC installed properly to run in C. Let's assume this is OK.

I'd check to see what's being passed as the data source name.

If you like, post the code.- Hide quoted text -

- Show quoted text -
Hi,
I am attaching the snippet in case I am using command line for
connecting to DSN and that works fine as shown below -

$ isql -v MySQLDSN root
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> quit

This is the code snippet when I use in C program -

retcode = SQLConnect(hdbc, (SQLCHAR*) "MySQLDSN", SQL_NTS, (SQLCHAR*)
"root", 0, NULL, 0);

$ ./a.out
Ret code :-1
Failed to create connection : [unixODBC][Driver Manager]Data source
name not found, and no default driver specified
 
S

spinoza1111

Hi,
I am trying to use ODBC on Unix platform. I have installed unixODBC
driver manager and mysql connector. When I try to use through command
line, unixODBC driver manager works fine, but when I write a code in C
and try to run, it gives me connection error -
[unixODBC][Driver Manager]Data source name not found, and no default
driver specified
I have my .odbc.ini file in my home directory and I have even set
ODBCINI pointing to the .odbc.ini file, but still I am getting this
error.
Will greatly appriciate any reply on the same.
Thanks
Shiv
Let's see. The connection error is from unixODBC, therefore you have
unixODBC installed properly to run in C. Let's assume this is OK.
I'd check to see what's being passed as the data source name.
If you like, post the code.- Hide quoted text -
- Show quoted text -

Hi,
I am attaching the snippet in case I am using command line for
connecting to DSN and that works fine as shown below -

$ isql -v MySQLDSN root
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> quit

This is the code snippet when I use in C program -

retcode = SQLConnect(hdbc, (SQLCHAR*) "MySQLDSN", SQL_NTS, (SQLCHAR*)
"root", 0, NULL, 0);

$ ./a.out
Ret code :-1
Failed to create connection : [unixODBC][Driver Manager]Data source
name not found, and no default driver specified

I haven't used ODBC in ten years, mind...but "for what it's worth",
Microsoft gives this as the syntax of the SQLConnect function at
http://msdn.microsoft.com/en-us/library/ms711810(VS.85).aspx:

SQLRETURN SQLConnect(
SQLHDBC ConnectionHandle,
SQLCHAR * ServerName,
SQLSMALLINT NameLength1,
SQLCHAR * UserName,
SQLSMALLINT NameLength2,
SQLCHAR * Authentication,
SQLSMALLINT NameLength3);

Are you missing the username length?

"For what it's worth". "Hope it helps". "Might be a mistake". "Honi
soit qui mal y pense".
 
K

Keith Thompson

SRK said:
I am trying to use ODBC on Unix platform. I have installed unixODBC
driver manager and mysql connector. When I try to use through command
line, unixODBC driver manager works fine, but when I write a code in C
and try to run, it gives me connection error -
[snip]

You'll get better answers in comp.unix.programmer -- or perhaps they
can direct you to an even better forum.
 
S

spinoza1111

Hi,
I am trying to use ODBC on Unix platform. I have installed unixODBC
driver manager and mysql connector. When I try to use through command
line, unixODBC driver manager works fine, but when I write a code in C
and try to run, it gives me connection error -
[unixODBC][Driver Manager]Data source name not found, and no default
driver specified
I have my .odbc.ini file in my home directory and I have even set
ODBCINI pointing to the .odbc.ini file, but still I am getting this
error.
Will greatly appriciate any reply on the same.
Thanks
Shiv
Let's see. The connection error is from unixODBC, therefore you have
unixODBC installed properly to run in C. Let's assume this is OK.
I'd check to see what's being passed as the data source name.
If you like, post the code.- Hide quoted text -
- Show quoted text -
Hi,
I am attaching the snippet in case I am using command line for
connecting to DSN and that works fine as shown below -
$ isql -v MySQLDSN root
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> quit
This is the code snippet when I use in C program -
retcode = SQLConnect(hdbc, (SQLCHAR*) "MySQLDSN", SQL_NTS, (SQLCHAR*)
"root", 0, NULL, 0);
$ ./a.out
Ret code :-1
Failed to create connection : [unixODBC][Driver Manager]Data source
name not found, and no default driver specified

I haven't used ODBC in ten years, mind...but "for what it's worth",
Microsoft gives this as the syntax of the SQLConnect function athttp://msdn.microsoft.com/en-us/library/ms711810(VS.85).aspx:

SQLRETURN SQLConnect(
     SQLHDBC        ConnectionHandle,
     SQLCHAR *      ServerName,
     SQLSMALLINT    NameLength1,
     SQLCHAR *      UserName,
     SQLSMALLINT    NameLength2,
     SQLCHAR *      Authentication,
     SQLSMALLINT    NameLength3);

Are you missing the username length?

"For what it's worth". "Hope it helps". "Might be a mistake". "Honi
soit qui mal y pense".

Looks to me like the call should be

SQLConnect(hdbc, (SQLCHAR*) "MySQLDSN", (SQLSMALLINT)8,
(SQLCHAR*)"root", (SQLSMALLINT)4, NULL, 0);

Try it out, let me know.
 
D

Dann Corbit

SRK said:
I am trying to use ODBC on Unix platform. I have installed unixODBC
driver manager and mysql connector. When I try to use through command
line, unixODBC driver manager works fine, but when I write a code in C
and try to run, it gives me connection error -
[snip]

You'll get better answers in comp.unix.programmer -- or perhaps they
can direct you to an even better forum.

Maybe something like this:
http://www.google.com/#hl=en&source=hp&q=unixodbc+howto&rlz=
1W1GGLD_en&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=9939b6bb0b4dafa4
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top