Sign in to follow this  
Followers 0
Steveyy

SQL Error beim Betrieb als .exe

13 posts in this topic

#1 ·  Posted (edited)

Hi zusammen!

Baue im Script eine SQL Verbindung auf mit

DRIVER={PostgreSQL ANSI};DATABASE=XXX;SERVER=localhost;Port=5432;Uid=XXX;Pwd=XXX

Wenn das Script aus dem Editor heraus läuft, funktionieren die Abfragen perfekt, als ich es jetzt jedoch zu einer .exe compiliert habe, bekomme ich folgenden Fehler, wenn die DB abgefragt wird:

[Microsoft][ODBC Diver Manager]

Der Datenquellenname wurde nicht gefunden, und es wurde kein Standardtreiber angegeben.

Fehlernummer: 80020009

Fehlerquelle: Microsoft OLE DB Provider for ODBC Drivers

und ein 2. Fehler:

Die Verbindung kann nicht verwendet werden, um diesen Vorgang auszuführen. Sie ist entweder geschlossen oder in diesem Zusammenhang ungültig.

Fehlerquelle: ADODB.Recordset

Hilfedatei: c:\Windows\HELP\ADO270.CHM

Helpcontext: 1240658

und noch weitere Hinweise:

Der Vorgang ist für ein geschlossenes Objekt nicht zugelassen.

Ein Objekt, das dem angeforderten Namen oder dem Ordinalverweis entspricht, kann nicht gefunden werden.

Weiß jemand, warum diese Fehler auftreten und wie man sie beheben kann?

Danke, Steveyy

Edited by Steveyy

Share this post


Link to post
Share on other sites



Hast Du Dich vom deutschen in das englische Forum verirrt? Du solltest die Frage hier in english formulieren damit Du Hilfe bekommst.

To get help from this forum you need to post your question in english.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello water, thank you for this hint, I'll post it in English.

I am establishing a SQL Connection in the script by using the following code:

DRIVER={PostgreSQL ANSI};DATABASE=XXX;SERVER=localhost;Port=5432;Uid=XXX;Pwd=XXX

When the script is run by the Editor (SciTE Light), the SQL queries work perfectly, but if I compile the script to an executable, I get the following errors, when the database is used:

[Microsoft][ODBC Diver Manager]

The Data Source hasn't been found. A standard driver has not been set.

Error Number: 80020009

Error Origin: Microsoft OLE DB Provider for ODBC Drivers

.. and a second error:

The connection cannot be established to execute this query. The connection is closed or invalid.

Error Origin: ADODB.Recordset

Helpfile: C:\Windows\HELP\ADO270.CHM

Helpcontext: 1240658

additional output:

This Query is not allowed for a closed Object.

An object, which equals the requested name, cannot be found.

Does somebody know, why these errors occour and how I can fix them?

Thanks, Steveyy

Edited by Steveyy

Share this post


Link to post
Share on other sites

Do you run the executable on the same machine as you run SciTe?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes, Win7 x64

Share this post


Link to post
Share on other sites

Next question: Do you use the same user or do you run the executable as a service?

Could you post the code where you establish the connection?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I use the same user.

Source code

Func getDatabaseValues($gdbv_param)

Local $gdbv_SQL

Local $gdbv_returner

Local $gdbv_one

Local $gdbv_two

If($gdbv_param <> "") Then

; connect

$oConn = ObjCreate("ADODB.Connection")

$oRS = ObjCreate("ADODB.Recordset")

$oConnstr = "DRIVER={PostgreSQL ANSI};DATABASE=XXX;SERVER=localhost;Port=5432;Uid=XXX;Pwd=XXX"

$ohand = $oConn.Open($oConnstr)

; SQL Statement

If($gdbv_param == "XXX") Then

$gdbv_SQL = "SELECT *"

Else

$gdbv_SQL = "SELECT * FROM data LIMIT 10"

EndIf

; execute Query

$oRS.Open($gdbv_SQL, $oConn, 1, 3)

; getting data

If Not $oRS.EOF Then

$gdbv_one = $oRS.Fields(0).Value

$gdbv_two = $oRS.Fields(1).Value

$gdbv_returner = $gdbv_one & $gdbv_two

EndIf

; closing DB conn

$oRS.Close

EndIf

; return value

Return $gdbv_returner

EndFunc

Share this post


Link to post
Share on other sites

Do you use an COM error handler in your script?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Are screenshots of the error windows valuable?

Global $STATE_ERROR = ObjEvent("AutoIt.Error","ErrFunc")

Func ErrFunc()

Local $sERR = _

"err.description is: " & @TAB & $STATE_ERROR.description & @CRLF & _

"err.windescription:" & @TAB & $STATE_ERROR.windescription & @CRLF & _

"err.number is: " & @TAB & hex($STATE_ERROR.number,8) & @CRLF & _

"err.lastdllerror is: " & @TAB & $STATE_ERROR.lastdllerror & @CRLF & _

"err.scriptline is: " & @TAB & $STATE_ERROR.scriptline & @CRLF & _

"err.source is: " & @TAB & $STATE_ERROR.source & @CRLF & _

"err.helpfile is: " & @TAB & $STATE_ERROR.helpfile & @CRLF & _

"err.helpcontext is: " & @TAB & $STATE_ERROR.helpcontext

Msgbox(0,"AutoItCOM","Ein COM-Fehler ist aufgetreten !" & @CRLF & @CRLF & $sERR)

Local $err = $STATE_ERROR.number

If $err = 0 Then $err = -1

Local $g_eventerror = $err

Endfunc

Share this post


Link to post
Share on other sites

When compiling your script do you use Obfuscator or UPX?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Maybe this thread It seems you have to define a DSN.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Yes, Win7 x64

Add this at top of your script

#AutoIt3Wrapper_UseX64=n

and compile script by F7 from full Scite4Autoit3

EDIT:

Explanation

I think your script was implicitly compiled as 64bit and your database driver is 32bit and this is cause of problems.

With my above directive your script will be compiled as 32bit even on X64 Windows

Edited by Zedna

Share this post


Link to post
Share on other sites

Thank you all alot! I think it was about the 32bit version of the SQL driver.

Compiling the script with F7 worked,

adding #AutoIt3Wrapper_UseX64=n and "compiling script to .exe" with 64bit did not work ( :D ),

Compiling script to .exe with ANSI and Unicode worked,

unfortunately I wasn't able to add a DSN datasource for PostgresSQL to Windows, so I could not try that out,

but I am happy to know it was about the 32bit driver.

Maybe I'll search for a x64 driver soon or I'll run this script in 32bit mode.

Thanks for your help!

Steveyy

Share this post


Link to post
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
Sign in to follow this  
Followers 0