ChrisL

_SQL.au3. ADODB.Connection

118 posts in this topic

I check:

declare @p11 varchar(255) set @p11='No Error' select @p11

Results are normal array with 'No Error'

and

I check:

DECLARE @topCount INT SET @topCount = '15' SELECT TOP (@topCount) * FROM [msdb].dbo.backupfile

Results are

 

Row|Col 0|Col 1|Col 2|Col 3|Col 4|Col 5|Col 6|Col 7|Col 8|Col 9|Col 10|Col 11|Col 12|Col 13|Col 14|Col 15|Col 16|Col 17|Col 18|Col 19|Col 20|Col 21|Col 22|Col 23|Col 24|Col 25
[0]|backup_set_id|first_family_number|first_media_number|filegroup_name|page_size|file_number|backed_up_page_count|file_type|source_file_block_size|file_size|logical_name|physical_drive|physical_name|state|state_desc|create_lsn|drop_lsn|file_guid|read_only_lsn|read_write_lsn|differential_base_lsn|differential_base_guid|backup_size|filegroup_guid|is_readonly|is_present
[1]|2|1|1|PRIMARY|8192|1|8616|D|512|71499776|BAZA|C:|C:!WORK!SQL_BAZA_AKTBAZA.mdf|0|ONLINE|0||{4A327C3A-7809-46BC-923E-4D2B4A8A32DF}|||||70582272|{00000000-0000-0000-0000-000000000000}|False|True
[2]|2|1|1|||2|2|L|512|86441984|baza_log|C:|C:!WORK!SQL_BAZA_AKTBAZA_1.ldf|0|ONLINE|0||{43D7BEBA-41D4-414D-A713-702D2216EF76}|||||8704||False|True

 

So I think you are using old MS SQL or you have an error in your SQL Query.

or ... Show me your connection string.

btw.

MS SQL 2014 EXPRESS


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites



I' am Using 2012 Express as Server. On the client Microsoft SQL Server Management Studio 11.0.2100.60

Microsoft Data Access Components (MDAC) 6.1.7601.17514.
 
The full query is:
;~ $sQuery =   "USE VIRTUAL SET NOCOUNT ON DECLARE @topCount INT SET @topCount = " &$nNumero &" SELECT TOP (@topCount) [NomeProduttore], [CodiceArticoloProduttore], [bando], [CodiceMetaclasse] " & _
;~ "FROM (SELECT [NomeProduttore], [CodiceArticoloProduttore], [bando], [CodiceMetaclasse], [PrezzoMepa] FROM [Virtual].[dbo].[Mepa_OfferteMigliorabili ] WHERE [PrezzoMepa] > " &$nPrezzoAcquistoMinimo &" ) t " & _
;~ "ORDER BY [PrezzoMepa] DESC;"
 
The connection function is ok .. because works for all' other queries.
 
Func My_SQL_Connessione($sPercorso, $sDatabase, $sUser, $sPassword)
; #FUNCTION# ====================================================================================================================
; Name...........: My_SQL_Connessione
; Description ...: Si collega al database SQL usando i parametri forniti
; Syntax.........:  My_SQL_Connessione ($sPercorso,$sDatabase,$sUser,$sPassword)
; Parameters ....: $sPercorso - Stringa contenente il percorso di rete del server
;                  $sDatabase - Stringa contenente il nome del datatabase SQL
;                  $sUser - Stringa contenente il nome dell' utente
;                  $sPassword - Stringa contenente la password
; Return values .: Success - Restituisce l' oggetto connessione - viene settato l' errore in caso di errore
;                  Failure - Returns 0 and sets @error ad 1 in caso la connessione non vada a buon fine
; ===============================================================================================================================
_SQL_RegisterErrorHandler()
Local $oConnessioneSQL = _SQL_Startup()
If $oConnessioneSQL = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())


If _sql_Connect(-1, $sPercorso, $sDatabase, $sUser, $sPassword) = $SQL_ERROR Then
   MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg(), 30)
  _SQL_Close()
   Return SetError(1, 0, 1)
EndIf
Return $oConnessioneSQL
EndFunc   ;==>My_SQL_Connessione

Share this post


Link to post
Share on other sites

dear @StefanoVR

1.

please read:

>How to post code on the forum

2.

Function header should be before function declaration

; #FUNCTION# ====================================================================================================================
; Name...........: My_SQL_Connessione
; Description ...: Si collega al database SQL usando i parametri forniti
; Syntax.........:  My_SQL_Connessione ($sPercorso,$sDatabase,$sUser,$sPassword)
; Parameters ....: $sPercorso - Stringa contenente il percorso di rete del server
;                  $sDatabase - Stringa contenente il nome del datatabase SQL
;                  $sUser - Stringa contenente il nome dell' utente
;                  $sPassword - Stringa contenente la password
; Return values .: Success - Restituisce l' oggetto connessione - viene settato l' errore in caso di errore
;                  Failure - Returns 0 and sets @error ad 1 in caso la connessione non vada a buon fine
; ===============================================================================================================================
Func My_SQL_Connessione($sPercorso, $sDatabase, $sUser, $sPassword)
    _SQL_RegisterErrorHandler()
    Local $oConnessioneSQL = _SQL_Startup()
    If $oConnessioneSQL = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())

    If _sql_Connect(-1, $sPercorso, $sDatabase, $sUser, $sPassword) = $SQL_ERROR Then
        MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg(), 30)
        _SQL_Close()
        Return SetError(1, 0, 1)
    EndIf
    Return $oConnessioneSQL
EndFunc   ;==>My_SQL_Connessione

3.

use Tidy before you post code.

 

4.

here you have connection string:

$ADODBHandle.Open("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";") ;<==Connect with required credentials

so you are using

$ADODBHandle.Open("DRIVER={SQL Server}; 

I use:

$ADODBHandle.Open("PROVIDER=SQLNCLI10;

check my updated _sql.au3

btw.

my updated _sql.au3 is still in BETA version.

and to see any special effect you must install MS sqlncli....

_sql.au3

1 person likes this

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

The full query is:

;~ $sQuery =   "USE VIRTUAL SET NOCOUNT ON DECLARE @topCount INT SET @topCount = " &$nNumero &" SELECT TOP (@topCount) [NomeProduttore], [CodiceArticoloProduttore], [bando], [CodiceMetaclasse] " & _
;~ "FROM (SELECT [NomeProduttore], [CodiceArticoloProduttore], [bando], [CodiceMetaclasse], [PrezzoMepa] FROM [Virtual].[dbo].[Mepa_OfferteMigliorabili ] WHERE [PrezzoMepa] > " &$nPrezzoAcquistoMinimo &" ) t " & _
;~ "ORDER BY [PrezzoMepa] DESC;"
 

 

did you test my sqlQuery ?

DECLARE @topCount INT SET @topCount = '15' SELECT TOP (@topCount) * FROM [msdb].dbo.backupfile

Do you have positive results, using my query ?


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#105 ·  Posted (edited)

mLipok, sorry for my bad post, not following forum rules.

I changed the UDF with the new one, made some modifications, and everything seems to work perfectly.

Thank you very much. 

Edited by StefanoVR

Share this post


Link to post
Share on other sites

mLipok, sorry for my bad post, not following forum rules.

 

It was not so bad.

Does not have anything to do with the forum rules.

Rather forum netiquette.

 

I changed the UDF with the new one, made some modifications, and everything seems to work perfectly.

What you changed ?

Please post here your modyfication.

Thank you very much.

I'am glad I could help.

Cheers

mLipok


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#107 ·  Posted (edited)

@mLipok

Using the new _sql.UDF i changed the connection code in order to use 'SQL Server Native Client 11.0'.

Now is:

Local $oConnessioneSQL = _SQL_Startup()
    If $oConnessioneSQL = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())


    If _sql_Connect(-1, $sPercorso, $sDatabase, $sUser, $sPassword, True) = $SQL_ERROR Then
        MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg(), 30)
        _SQL_Close()
        Return SetError(1, 0, 1)
    EndIf

Using this drifferent driver I changed some query that had "USE [DatabaseName] SELEC .... ] that was in my code.

In the old version worked but with the new driver they answed "UNABLE TO RETRIVE DATA" and I saw more errors in _SQL_ErrFunc().

But really I have a new problem.. a very strange behavior.

I use a SQL stored procedure on server that returns a specific value.

$sQuery = "DECLARE @return_value INT EXEC @return_value = [dbo].[ContatoreUtente] @utente = N'" & $sgUtente & "' SELECT 'Return Value' = @return_value;"
$sEsitoQuery = _SQL_GetTable($oConnessioneSQL, $sQuery, $aRisultatoQueryStored, $nRigheTabellaQueryStored, $nColonneTabellaQueryStored)
If $sEsitoQuery = 1 Then
                      Local $sErroreSQL = _SQL_GetErrMsg()
    ClipPut($sQuery)
    MsgBox(0, "DBG-Errore", "Errore nella Query di Ricerca della data minima delle offerte del fornitore in elaborazione nella metaclasse in elaborazione: " & @CRLF & $sQuery & @CRLF & "ERRORE SQL: " & $sErroreSQL)
EndIf
_ArrayDisplay($aRisultatoQueryStored) ;DBG
$nValoreRestituitoStoredProcedure = $aRisultatoQueryStored[2]

In the previous version worked perfecly and the value that I need was in $nValoreRestituitoStoredProcedure = $aRisultatoQueryStored[2].

With the new version hangs up WHITOUT ANY ERROR.. :

I attemped to do some tests.. using this code:

$sQuery = "DECLARE @return_value INT EXEC @return_value = [dbo].[ContatoreUtente] @utente = N'" & $sgUtente & "' SELECT 'Return Value' = @return_value;"

;~      $sEsitoQuery = _SQL_GetTable($oConnessioneSQL, $sQuery, $aRisultatoQueryStored, $nRigheTabellaQueryStored, $nColonneTabellaQueryStored)
;~      If $sEsitoQuery = 1 Then
;~          Local $sErroreSQL = _SQL_GetErrMsg()
;~          ClipPut($sQuery)
;~          MsgBox(0, "DBG-Errore", "Errore nella Query di Ricerca della data minima delle offerte del fornitore in elaborazione nella metaclasse in elaborazione: " & @CRLF & $sQuery & @CRLF & "ERRORE SQL: " & $sErroreSQL)
;~      EndIf

;~      Func _SQL_GetTable($hConHandle, $vQuery, ByRef $aData, ByRef $iRows, ByRef $iColumns)

        Local $i, $objquery, $aNames
        Local $SQLErr = ""
        Local $iRows = 0
        Local $iColumns = 0
        Dim $aData[1] = [0]

        $objquery = _SQL_Execute($oConnessioneSQL, $sQuery)

        If @error Then
            $SQLErr = "Query Error"
        EndIf

        If $objquery.eof Then
            $SQLErr = "Query has no data"
            $objquery = 0 ;sp mod
        EndIf

        _SQL_FetchNames($objquery, $aNames)

        $iColumns = UBound($aNames)

        ReDim $aData[$iColumns + 1]

        $aData[0] = $iColumns

        For $i = 0 To $iColumns - 1
            $aData[$i + 1] = $aNames[$i]
        Next

        $aNames = 0

        While Not $objquery.eof
            $iRows += 1
            For $i = 0 To $objquery.Fields.Count - 1
                ReDim $aData[$aData[0] + 2]
                $aData[0] += 1
                $aData[$aData[0]] = $objquery.Fields($i).Value
            Next
            $objquery.MoveNext; Move to next row
        WEnd
        $objquery = 0 ;sp mod

Query executes correctly and also the error checks are ok.. and $objquery exists.

So _SQL_FetchNames($objquery, $aNames) exit without errors but $aNames is an empty array.. and then

While Not $objquery.eof ->Wend goes in an infinite loop..

Probably I' am doing something wrong but I can't uderstand.

Edited by StefanoVR

Share this post


Link to post
Share on other sites

@mLipok

 

Using the new _sql.UDF i changed the connection code in order to use 'SQL Server Native Client 11.0'.

 

some modyfication:

; #FUNCTION# ====================================================================================================================
; Name ..........: _SQL_CONNECTION_STRING_SQLAuth
; Description ...:
; Syntax ........: _SQL_CONNECTION_STRING_SQLAuth($sServer, $sDataBase, $sUserName, $sPassword[, $bUseProviderInsteadDriver = True])
; Parameters ....: $sServer             - A string value.
;                  $sDataBase           - A string value.
;                  $sUserName           - A string value.
;                  $sPassword           - A string value.
;                  $bUseProviderInsteadDriver- [optional] A binary value. Default is True.
; Return values .: $__sSQL_Last_ConnectionString
; Author ........: mLipok
; Modified ......:
; Remarks .......: TODO - description
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SQL_CONNECTION_STRING_SQLAuth($sServer, $sDataBase, $sUserName, $sPassword, $bUseProviderInsteadDriver = True)
    If $bUseProviderInsteadDriver then
        $__sSQL_Last_ConnectionString = "PROVIDER=" & _SQL_PROVIDER_VERSION() & ";SERVER=" & $sServer & ";DATABASE=" & $sDataBase & ";uid=" & $sUserName & ";pwd=" & $sPassword & ";"
    Else
        $__sSQL_Last_ConnectionString = "DRIVER={" & _SQL_DRIVER_VERSION() & "};SERVER=" & $sServer & ";DATABASE=" & $sDataBase & ";uid=" & $sUserName & ";pwd=" & $sPassword & ";"
    EndIf
    Return $__sSQL_Last_ConnectionString
EndFunc   ;==>_SQL_CONNECTION_STRING_SQLAuth

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

@StefanoVR

Do you have any new observations or modifications to my revised version of this UDF ?

1 person likes this

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Really now everything works. I couldn't identify the error. Probably was a my (wrong) modification.

I downloaded again your original UDF and now is ok.

Thank you very much for the support. 

Stefano 

Share this post


Link to post
Share on other sites

so, I have been using _sql.au3 to capture and record data from various pc's. and now Im just looking to pull data once in while.

I'm seeing something strange.

Local $aData,$iRows,$iColumns;Variables to store the array data in to and the row count and the column count
    $iRval = _SQL_GetTable2D(-1,"SELECT * FROM MigInfo WHERE [User] LIKE 'pwmill%';",$aData,$iRows,$iColumns)
    If $iRval = $SQL_OK then _arrayDisplay($aData,"2D  (" & $iRows & " Rows) (" & $iColumns & " Columns)" )

this is straight from the example code. and as you can see I query a table for a specific user. the query pulls all the data, but will not display some of the columns it in the array. (see attachment).

I can run the data to string from the example code, and I receive ALL data. the query does work, it's just wont display in the array.

thought?

 

post-49189-0-15287700-1377181478_thumb.j

I know this is a really old comment, but I just ran into the exact same problem. I finally figured it out myself, and sinceI was scratching my head for a while because of it I thought I'd share the solution.

In digging into the query that was giving me the blank columns, I noticed that for all problem fields the data type of the underlying field was varchar(max). Apparently there's something that either the _SQL UDF or AutoIt itself doesn't like about working with that data type.

I was able to get around it by modifying the View in the SQL table that I was referencing with my _SQL UDF functions. For each field that has a varchar(max) data type, use either CAST or CONVERT to force the data into a type that is digestible by your AutoIt script. In my case, I had to cast one field as int, one as varchar(256) (for a UNC path) and the other as decimal(16 , 10) (for a decimal-formatted timestamp value). When adding the CAST functions within SQL Server Management Studio I got a prompt warning that the conversion might not be necessary, but in my case they were safe to ignore. After saving these changes to the View, voila - the columns were no longer blank!

Be mindful that you don't convert the data in a way that could produce undesired or unpredictable results, *especially* if your AutoIt script isn't the only thing that relies on the View (in my case, I built the View specifically for my AutoIt script). I would actually highly recommend that you also create a View specifically for this conversion purpose, rather than change the data types in the underlying table.


An emoticon is worth a dozen words.

Share this post


Link to post
Share on other sites

I believe that the SQL ADO connector you use doesn't work well with varchar(max) datatype.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

I believe that the SQL ADO connector you use doesn't work well with varchar(max) datatype.

Hi jchd,

I'm using _sql.au3 modified to use the SQL Server Native Client 11.0 connector - do you think it could still be a factor?


An emoticon is worth a dozen words.

Share this post


Link to post
Share on other sites

#114 ·  Posted (edited)

How you have modified it ?

Did you try my version ?

 

Edited by mLipok
wording

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

New Version:

 

 

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#116 ·  Posted (edited)

Is the ADO.au3 the same as _SQL.au3?

I'm trying just to connect to our SQL Server. I have used ADO.au3 until now I haven't succeed to connect to our SQL server. Now I will try _SQL.au3, but how do I connect to the SQL server with _SQL.au3?

Edited by Valnurat

Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#117 ·  Posted (edited)

15 minutes ago, Valnurat said:

Is the ADO.au3 the same as _SQL.au3?

I'm trying just to connect to our SQL Server. I have used ADO.au3 until now I haven't succeed to connect to our SQL server. Now I will try _SQL.au3, but how do I connect to the SQL server with _SQL.au3?

It use the same technology ADO ActiveX.
Functions are quite different, but _SQL.au3 was a precursor, I can even say that my ADO.au3 is strongly rewrited version of _SQL.au3

Sorry for my lack of answer in ADO.au3 support thread - I was busy at work.
Let's back to ADO.au3.
 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#118 ·  Posted

Ok. Let's do that. :)


Yours sincerely

Kenneth.

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