Opening ODBC database


Andreschrosa
 Share

Recommended Posts

When trying to open ODBC database from scripting, I run in the following error:

O1002 Unable to open ODBC database: lookup Line 14 - Uncaught error in sequence lookup

global string DSN
global string user
global string passw
private handle
private result

DSN = 'DSLeituras'
user = 'root'
passw = ''
handle = db.open(DSN, user, passw) ///this is line 14///

anything wrong with this declaration? :rolleyes:

Link to comment
Share on other sites

Possibly. First, did you create an ODBC data source for your database, or is DSLeituras the actual name of the database? DAQFactory does not connect directly to databases, but rather uses ODBC as a linkage. You therefore have to create an ODBC data source. The user / password combination is usually for the ODBC linkage and not the database itself. You usually specify the database user/password when setting up the ODBC.

Link to comment
Share on other sites

Yes, I did crate the datasource using mysql.

I'm running windows vista 32 bits by the way.

Tried using:

handle = db.OpenEx("DSN ='DSLeituras'; UID ='root';PWD=;DATABASE ='leituras'")

then it returns the following error:

O1002 Unable to open ODBC database: lookup Line 14 - Uncaught error in sequence lookup

Link to comment
Share on other sites

You can't create the datasource in mySql. DataSources are an ODBC thing which is a windows thing, not a mysql thing. You will need to get the MySQL ODBC connector which is available from their website, install it, then create a datasource with it from windows ODBC settings (under administrator settings / ODBC). It is described in our help in general terms in the logging chapter.

Link to comment
Share on other sites

OK, in the logging set you are presumably not specifying a user name, right? So try opening it without using a user name. If that doesn't work, try creating a blank document and then open it from there. Its possible that the logging set is interfering with the db.open command.

Link to comment
Share on other sites

No good yet... tried opening a new document in DAQFactory and pasting the code there, it still dosent work.

I'm guessing it could have something to do with regional settings or somesuch, tried using "" and '' for the strings, but still no good.

Are those parameters from DAQFactory? DSN, UID, PWD, DATABASE? Or those should be particular to the mysql sql script?

global handle
handle = DB.OpenEx('DSN=dsleituras;UID=;PWD=;DATABASE=leituras')

Link to comment
Share on other sites

When you use OpenEx(), the string you specify is passed directly to ODBC, so the parameters are ODBC not DAQFactory. This is to allow complete control over the open string. I believe in the logging set (which uses a different technique to open databases than the db.openex() function) it opens with the string: "DSN=mydsn; ODBC;" where mydsn is the datasource string you specified in the logging set. Perhaps you just need the ODBC; at the end?

Link to comment
Share on other sites

Sure, but as I said, this works with logging set.

After some searching on mysql developer network, I found some parameter to connect to the datasource, however, this also dosent work.

handle = DB.OpenEx("DSN='SLeituras'ODBC;DRIVER='{MySQL ODBC 5.1 Driver}';SERVER='localhost';DATABASE='leituras';UID='';PWD='';OPTION='3'")

screenshot of the ODBC configuration:

ODBC.jpg

Link to comment
Share on other sites

Note you have two typos in that last script, the DSN is wrong and you forgot the ; before ODBC.

Try these:

1) Open using Open() instead of OpenEx(). Unless you specified a user/password in the details of ODBC (not the "root" you specified), you should pass "" for user and password.

2) User this string:

handle = DB.OpenEx("DSN='DSLeituras'; UID=''; PWD=''; ODBC;)

Much of that extra stuff you specified in that last post does nothing because its in the ODBC driver.

Link to comment
Share on other sites

  • 4 months later...

I have the exact problem right now. db is working if using logging. But I cannot open it via script. The error is either cannot open or unknown error. I actually have tried all what you have tried before finding this post. I would like to ask how the issue is solved?

database name: ewsdb

odbc connector name: ews_data

odbc driver: mysql odbc 5.1 driver

Thanks.

Link to comment
Share on other sites

Not sure. It was, I believe, a syntax error, but Andreschrosa never replied saying it worked. Note that in this line:

handle = DB.OpenEx("DSN='DSLeituras'; UID=''; PWD=''; ODBC;")

the '' after UID and PWD are two single quotes ' and ', not a single double quote "

For you, the database name and type don't matter. Only the data source name: ews_data

I believe someone else had a problem where they created a datasource as a system DSN but it needed to be a user DSN. Its a recent post if I remember, probably under logging.

Link to comment
Share on other sites

I believe that it is kinda like a bug in daqfactory. The following is what I have now:

Using MySQL ODBC Connector 3.51:

db.Open("ews_data") : Working

Logging method: Working

Using MySQL ODBC Connector 5.1:

db.Open("ews_data"): O1003 Unknown error accessing ODBC database

Logging method: Working

So please verify which and what is wrong. It is definitely not some grammar issue at the user's side.

post-822-1236047716_thumb.jpg

Link to comment
Share on other sites

Nope, not a bug. DAQFactory simply calls the Windows API for ODBC, and certainly the fact it works in the logging set means DAQFactory is fine. The issue is your connection string. Obviously there is some difference in it that is making it not work. I believe the logging set adds "ODBC;" to the end of the connection string, so maybe that is it.

Link to comment
Share on other sites

  • 6 months later...

Hi,

I am also facing same problem. I can open the ODBC database in logging & exporting. But, when I try to open it from sequence using both db.open and db.openEx methods, I am getting

"O1002 Unable to open ODBC database: s1 Line 5 - Uncaught error in sequence s1"

Please let me know how to resolve this issue?

Thank you

Link to comment
Share on other sites

  • 1 year later...

dbase = db.Open("janitza")

this is my connection code to "Mysql Connector 5.1".. It works fine . and i defined user =root and a password for it. this statemnet needs too much experiment i think. i was uninstall the database server and the connector driver to solve that connection problems. But i can say Mysql connector doesn't need "OpenEx" function. you can write user and password on connectors interface..

Link to comment
Share on other sites

  • 6 years later...

I'm not sure.  That post was from 6 years ago.  If you don't need a user / password, I would just use db.open().  If that doesn't work, there are several possibilities, but the most likely one is:

DAQFactory is a 32 bit application, so you have create your ODBC data sources in the 32 bit version of ODBC.  On 64 bit versions of windows there are actually two ODBC control panels, one for 32 bit, and one for 64.  Unfortunately, only the 64 bit version shows in control panel.  Personally, I added a shortcut to the 32 bit version to my control panel.  The path on my computer is:

C:\Windows\SysWOW64\ODBCCP32.CPL

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share