Jump to content

access help reqd


skippynz
 Share

Recommended Posts

hi ppl - i have a script where im reading in 2 columns from an access 2003 database - this use to work and from memory i havent changed anything so im not sure whats happening now. i get the error below and i know what is causing the error but i just dont know how to fix it - so i come to you the autoit gods....:)

Line -1:

Error: The requested action with this object failed

I'm reading an INI for the values of my mdb file location and SQL command so heres what ive got - hopefully someone can shed som light on what im doing wrong.

Heres the INI file

[database]
location=Invent.mdb                             
sqlcode=SELECT Server,Shutdown from ServerInfo

the short version of my code is here - the error appears after this line "$RecordSet = ObjCreate('ADODB.Recordset')" run successfully.

#Include <Array.au3>
#Include <File.au3>
#Include <Process.au3>

$INIFILE = 'Patching.ini'

$FULL_MDB_FILE_NAME = IniRead($INIFILE,'database','location','')
$SQL_CODE = IniRead($INIFILE,'database','sqlcode','')

$CONN = ObjCreate('ADODB.Connection')
$CONN.Open('Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $FULL_MDB_FILE_NAME & ';')
$RecordSet = ObjCreate('ADODB.Recordset')
$RecordSet.Open($SQL_CODE, $CONN)
$data = $RecordSet.GetRows()
$RecordSet.Close
$CONN.Close

TIA - Craig

Link to comment
Share on other sites

hi ppl - i have a script where im reading in 2 columns from an access 2003 database - this use to work and from memory i havent changed anything so im not sure whats happening now. i get the error below and i know what is causing the error but i just dont know how to fix it - so i come to you the autoit gods....:)

Line -1:

Error: The requested action with this object failed

I'm reading an INI for the values of my mdb file location and SQL command so heres what ive got - hopefully someone can shed som light on what im doing wrong.

Heres the INI file

[database]
location=Invent.mdb                             
sqlcode=SELECT Server,Shutdown from ServerInfo

the short version of my code is here - the error appears after this line "$RecordSet = ObjCreate('ADODB.Recordset')" run successfully.

#Include <Array.au3>
#Include <File.au3>
#Include <Process.au3>

$INIFILE = 'Patching.ini'

$FULL_MDB_FILE_NAME = IniRead($INIFILE,'database','location','')
$SQL_CODE = IniRead($INIFILE,'database','sqlcode','')

$CONN = ObjCreate('ADODB.Connection')
$CONN.Open('Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $FULL_MDB_FILE_NAME & ';')
$RecordSet = ObjCreate('ADODB.Recordset')
$RecordSet.Open($SQL_CODE, $CONN)
$data = $RecordSet.GetRows()
$RecordSet.Close
$CONN.Close

TIA - Craig

Add a COM error handler (see help file) so you can get more information.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

ok did as you suggested - and i get the following attached message

thanks

Craig

thanks for the help with the com - will have to remember that one for next time - i added some more lines to the messagebox that appears and found it was the comment fields i had added to my INI file that was causing the problem...:)

Link to comment
Share on other sites

thanks for the help with the com - will have to remember that one for next time - i added some more lines to the messagebox that appears and found it was the comment fields i had added to my INI file that was causing the problem...:)

Gotta' learn things the hard way... I can relate!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...