Jump to content
Sign in to follow this  
gcue

get results from a SQL query

Recommended Posts

gcue

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

Share this post


Link to post
Share on other sites
gcue

got it working through PSALTY's example

thanks psalty for sharing and those who helped him!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.