Jump to content

ADO_Example issue - [Microsoft][ODBC Driver Manager] Data source name too long


Recommended Posts

I'm trying the ADO example in reference to MS Access.

I'm running win 10, MS Access 2016

I grabbed the beta 2.1.15 files from the ado entry here -> 

 

 

I placed ADO.au3 and ado_cnstants.au3 in my includes folder and the other files in my working directy of autoit on my desktop and am running ado_example exactly as it came from the file with the following tweaks.

I have added the 64bit switch to the top, thinking that was my issue, but alas... nope and the debugging code in the event it hangs at some point - that moves everything down 3 lines in line numbers. so when I say line 28, it would be line 25 in the original file) These lines are what I added ->

AutoItSetOption ("TrayIconDebug", 1)
#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection(True);required? since 64bit MsAccess so 64 bit functionality required?

line 28 uncommented the _Example_MSAccess() - the rest of the examples are still commented - run it at this point and I get a variable used without being declared on line 43 in reference to $FileFullPath - this doesn't appear in the file but on line 38 there is a var named $sMDB_FileFullPath ... so I changed to that and assumed it didn't get updated in a recent change. I also set that variable to this instead of "default" -> 'c:\users\myusernam\desktop\autoit\testdb.accdb'

At this point I get:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\myusernam\Desktop\autoit\ADO_EXAMPLE.au3"    
###############################
ADO.au3 v.2.1.15 BETA (1100) : ==> COM Error intercepted !
$oADO_Error.description is:     [Microsoft][ODBC Driver Manager] Data source name too long
$oADO_Error.windescription:     Exception occurred.

$oADO_Error.number is:     80020009
$oADO_Error.lastdllerror is:     0
$oADO_Error.scriptline is:     1100
$oADO_Error.source is:     Microsoft OLE DB Provider for ODBC Drivers
$oADO_Error.helpfile is:     
$oADO_Error.helpcontext is:     0
###############################
###############################
ADO.au3 v.2.1.15 BETA (1100) : ==> COM Error intercepted !
$oADO_Error.description is:     [Microsoft][ODBC Driver Manager] Data source name too long
$oADO_Error.windescription:     Exception occurred.

$oADO_Error.number is:     80020009
$oADO_Error.lastdllerror is:     0
$oADO_Error.scriptline is:     1100
$oADO_Error.source is:     Microsoft OLE DB Provider for ODBC Drivers
$oADO_Error.helpfile is:     
$oADO_Error.helpcontext is:     0
###############################
###############################
ADO.au3 v.2.1.15 BETA (1100) : ==> COM Error intercepted !
$oADO_Error.description is:     [Microsoft][ODBC Driver Manager] Data source name too long
$oADO_Error.windescription:     Exception occurred.

$oADO_Error.number is:     80020009
$oADO_Error.lastdllerror is:     0
$oADO_Error.scriptline is:     1100
$oADO_Error.source is:     Microsoft OLE DB Provider for ODBC Drivers
$oADO_Error.helpfile is:     
$oADO_Error.helpcontext is:     0
###############################
>Exit code: 0    Time: 0.3115

Am I doing something incorrectly here or is the example incompatible with my setup or what? The db itself is a very tiny chunk of dummy data. Single table. 2 fields of short text. 8 total entries with a single character in each firled. 1-0 a-f ie: first entry is 1 and 2. second is 3 and 4. etc

note: commenting out my 3 lines of custom code at the top has the same results.

Link to comment
Share on other sites

1) I always use this directive in all my scripts: #AutoIt3Wrapper_UseX64=n

2) Post your DSN (Data Source Name) string

3) try minimalistic version of connection without ADO UDF like this (to see if it works):

$oConn = ObjCreate("ADODB.Connection")
$DSN = "Driver={SQL Server};Server=%server%;Database=%database%;Uid=%name%;Pwd=%password%;"
$oConn.Open($DSN)

 

Edited by Zedna
Link to comment
Share on other sites

Thanks!

I'm apparently missing something key because this didn't work either. (This is my first go at interfacing with a database so I'm probably missing numerous key things actually). I'm using MS Access 2016, not SQL Server, not sure if that makes a difference in the code so I tried it both ways with similar results. Neither worked, so I stepped back and challenged my assumptions and eventually made some progress. In case another newbie comes across this post it is below...

First, that a local install of MS Access would already have all it needs for me to interact with it. Turns out, not so much...

Looking at these steps that I found online seems to indicate that I might be missing something:

Here is how to create a connection to a MS Access Database: 

  1. Open the ODBC icon in your Control Panel.
  2. Choose the System DSN tab.
  3. Click on Add in the System DSN tab.
  4. Select the Microsoft Access Driver. Click Finish.
  5. In the next screen, click Select to locate the database.
  6. Give the database a Data Source Name (DSN).
  7. Click OK.

Note that if you are on a 64 bit OS you many not have the MS Access Driver in the list if you want theACCDB extension. Windows 7 (maybe others too?) don't have a 64bit option for this by default but it is there. You just use the 32bit utility by accessing it directly (c:\windows\sysWOW64\odbcad32.exe) (Source: answers.microsoft.com/en-us/office/forum/officeversion_other-office_other/64-bit-driver-for-dsn-for-ms-access-database/be8c0ad4-d8fd-48e0-9026-b95d84135820 ). What it doesn't tell you is that there isn't a specific 2016 version, I used the 2010 install to get the AACDB access. That allowed me to complete the above 7 steps to get the DSN, which I didn't know I needed to start with.

 

Thanks again for the assistance!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...