Jump to content

get results from a SQL query


gcue
 Share

Recommended Posts

hello world.

I am trying to get the results of this sql query. I am not getting any errors so I think I should be getting results back.

thanks in advance!

#include <array.au3>

$msg_normal = 0

$oConn = _SQLConnect($sServer, $sNetworkAddress, $sDatabase, 1, $sUsername, $sPassword)

if @error Then
MsgBox(0,"","error")
EndIf


$oCmd = ObjCreate("ADODB.Command")
$oCmd.ActiveConnection = $oConn

$oCmd.CommandText = "exec storedproc 'XYZ' "
$returnVal = $oCmd.Execute

$oConn.close

debug($returnVal)


Func _SQLConnect($sServer, $sNetworkAddress, $sDatabase, $fAuthMode = 0, $sUsername = "", $sPassword = "", $sDriver = "{Sybase ASE ODBC Driver}")
Local $sTemp = StringMid($sDriver, 2, StringLen($sDriver) - 2)
Local $sKey = "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers", $sVal = RegRead($sKey, $sTemp)
If @error Or $sVal = "" Then Return SetError(2, 0, 0)
$oConn = ObjCreate("ADODB.Connection")
If Not IsObj($oConn) Then Return SetError(3, 0, 0)
If $fAuthMode Then $oConn.Open("DRIVER=" & $sDriver & ";DSN=" & $sServer & ";NA=" & $sNetworkAddress & ";DATABASE=" & $sDatabase & ";UID=" & $sUsername & ";PWD=" & $sPassword)
If Not $fAuthMode Then $oConn.Open("DRIVER=" & $sDriver & ";SERVER=" & $sServer & ";DATABASE=" & $sDatabase)
If @error Then Return SetError(1, 0, 0)
Return $oConn
EndFunc

Func Debug($variable1 = "", $variable2 = "", $variable3 = "")

If IsArray($variable1) Then
_ArrayDisplay($variable1)
Else
If $variable2 <> "" Then
$variable1 &= @CRLF & $variable2
EndIf

If $variable3 <> "" Then
$variable1 &= @CRLF & $variable3
EndIf

ClipPut($variable1)
MsgBox($msg_normal, "Debug", $variable1)
EndIf

EndFunc ;==>Debug
Edited by gcue
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...