Jump to content

Recommended Posts

Posted (edited)
  On 8/15/2023 at 10:02 PM, Champak said:

only pick up com errors from this udf

Expand  

Exactly only from this UDF.
This is what was may intention to differ COM errors from different sources.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 5 weeks later...
Posted (edited)

Hi All :)

Can anyone tell me how to save MSSQL BLOB to file.
_ADO_Execute returns me a table with binary content:

1 0xFFD8....
2 0xFC3A....
3 0x736F...
...

I tried to combine all the lines into one and save to disk using filewrite.
Unfortunately, the file (jpeg) is invalid.

Edited by Zmylna
Posted (edited)

No wonder that you get an invalid image file since you are keep overwriting $line with the content of the last blob data. Why not something like this?

$line &= $aZalacznik[$n][0]

And since it's binary data, don't forget about 0x prefix, so you have to strip the prefix for each blob and append it once to the final binary string, just before you write the content to the file.

$line &= StringTrimLeft($aZalacznik[$n][0], 2)
...
FileWrite($hFile, '0x' & $line)

 

Edited by Andreik
Posted
  On 9/15/2023 at 2:57 PM, Zmylna said:

1 0xFFD8....
2 0xFC3A....
3 0x736F.

Expand  

String to binary.... binary to file....

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 9/15/2023 at 8:35 PM, Andreik said:

No wonder that you get an invalid image file since you are keep overwriting $line with the content of the last blob data. Why not something like this?

$line &= $aZalacznik[$n][0]

And since it's binary data, don't forget about 0x prefix, so you have to strip the prefix for each blob and append it once to the final binary string, just before you write the content to the file.

$line &= StringTrimLeft($aZalacznik[$n][0], 2)
...
FileWrite($hFile, '0x' & $line)

 

Expand  

Works very well :)
Thank you, that was the point :)

Posted

Please mark your working solution.

Proszę oznacz działające rozwiązanie.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Yeap.

My mistake.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Hi @mLipok :)

I have a question for you if I may regarding the _ADO_Execute function.
In my program i performs a query to the database.
The result of the query is correct but the MS Profiler registers three identical queries to the database. Why ?

$query="exec w****s @UserSessionID=******,@ModulID=******,@fts=N'''******'',''******'',''******'',''******''',@******='******',@**='******'"
Func sql_exec($squery)
    ; Wykonanie zapytania SQL
    consolewrite("Wykonanie polecenia SQL: " &  $squery &  @CRLF)
    Local $oRecordset = _ADO_Execute($oConnection, $squery, True)

    Return $oRecordset[2]
EndFunc   ;==>sql_exec

 

What the MS Profiler shows:
SQL:BatchStarting    exec ****** @UserSessionID=*****,@ModulID=***,@fts=N'''*****'',''*****'',''*****'',''*****''',@*****='*****',@**='*****'    *****        user                    14656    1031    
SQL:BatchCompleted    exec ****** @UserSessionID=*****,@ModulID=***,@fts=N'''*****'',''*****'',''*****'',''*****''',@*****='*****',@**='*****'    *****        user    454    228094    0    450    14656    1031    
SQL:BatchStarting    exec ****** @UserSessionID=*****,@ModulID=***,@fts=N'''*****'',''*****'',''*****'',''*****''',@*****='*****',@**='*****'    *****        user                    14656    1031    
SQL:BatchCompleted    exec ****** @UserSessionID=*****,@ModulID=***,@fts=N'''*****'',''*****'',''*****'',''*****''',@*****='*****',@**='*****'    *****        user    453    220456    0    442    14656    1031    
SQL:BatchStarting    exec ****** @UserSessionID=*****,@ModulID=***,@fts=N'''*****'',''*****'',''*****'',''*****''',@*****='*****',@**='*****'    *****        user                    14656    1031    
SQL:BatchCompleted    exec ****** @UserSessionID=*****,@ModulID=***,@fts=N'''*****'',''*****'',''*****'',''*****''',@*****='*****',@**='*****'    *****        user    437    220456    0    442    14656    1031

Posted (edited)
  On 9/21/2023 at 9:46 AM, Zmylna said:

the MS Profiler registers three identical queries to the database. Why ?

Expand  

If I remember well it was already discussed here.

But currently I do not remember the details.

I will take fresh look today in the evening or tomorrow.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

@Zmylna in your PM you was pointing me to:

 

but you should check this:

 

especially;

  

  On 8/29/2021 at 1:13 AM, mLipok said:

Feel warned about:

# !!! WARNING !!! this following line has an issue - the inserted data are inserted 3 times !!!
;~  Local $aRowsResult = _ADO_Execute($oConnection, $s_SQLQuery_InsertBinaryContent, True)
    # BECAUSE OF THIS ISSUE:   !!!!  use $bReturnAsArray = False .... like in following line
    Local $oRecordset = _ADO_Execute($oConnection, $s_SQLQuery_InsertBinaryContent, False)

 

image.png.aadde58c9ff61a9a689f95b16c00ba47.png

 

This is a bug that I have noticed before, so far I don't know why it occurs.

I will gladly use any help in solving it.

Expand  

 

and this following statement is still valid:  

  On 8/29/2021 at 1:13 AM, mLipok said:

This is a bug that I have noticed before, so far I don't know why it occurs.
I will gladly use any help in solving it.

Expand  


Any help ?

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Thank you for your answer @mLipok

I changed the code to this:

Func sql_exec($squery)
    ; Procedura wykonująca zapytania do serwera SQL

    ; Wykonanie zapytania SQL
    ConsoleWrite("Wykonanie polecenia SQL: " & $squery & @CRLF)
    Local $oRecordset = _ADO_Execute($oConnection, $squery, False)

    ; Przerzucenie wyników zapytania do tablicy
    Local $aRecordsetArray = _ADO_Recordset_ToArray($oRecordset, False)
    Local $aRecordset_inner = _ADO_RecordsetArray_GetContent($aRecordsetArray)


    ;Return $aRecordset_inner
    If IsArray($aRecordset_inner) Then
        Return $aRecordset_inner
    Else
        Return ""
    EndIf
EndFunc   ;==>sql_exec

Unfortunately, the problem persists.
SQL Server is queried three times during one execution of _ADO_Execute

Posted

You missunderstand this.

DO NOT GET RESULT ARRAY from sql insert statement

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 9/22/2023 at 10:09 AM, Zmylna said:
; Przerzucenie wyników zapytania do tablicy
    Local $aRecordsetArray = _ADO_Recordset_ToArray($oRecordset, False)
Expand  

You use $oRecordset.getrows()

Which regenerate recordset.... at least I think so.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
×
×
  • Create New...