Sign in to follow this  
Followers 0
Warmonger

Two ADODB.Connection's One Function

6 posts in this topic

#1 ·  Posted (edited)

How would it be done?

Example

Func _Ban()
    $sqlCon = ObjCreate('ADODB.Connection')
    $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
    $Query = 'Select Bla Bla From Bla where bla=bla'
    $Result = $sqlCon.Execute($Query)
        $sqlCon = ObjCreate('ADODB.Connection')
        $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
        $Query = 'Select Bla Bla From Bla Where bla=' & $Result.GetString
        $sqlCon.Execute($Query)
    TCPSend($sSocket[$x], 'Player ' & $sFilter[2] & ' Has Been Banned!')
EndFunc
Edited by Warmonger

Share this post


Link to post
Share on other sites



Please don't do that. When you solve a problem, leave the problem and the solution in the forum for others as a future reference through the search function. It reduces the value of the site over time if the problems/solutions get deleted.

:unsure:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Please don't do that. When you solve a problem, leave the problem and the solution in the forum for others as a future reference through the search function. It reduces the value of the site over time if the problems/solutions get deleted.

:unsure:

I would of but the problem wasnt solved. And the function wasnt something I wanted to post. I will remake original topic. Since this issue I cannot solve with a quick example function. Edited by Warmonger

Share this post


Link to post
Share on other sites

Here are two possible way how to do it:

Func _Ban()
    $sqlCon = ObjCreate('ADODB.Connection')
    $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
    $Query = 'Select Bla Bla From Bla where bla=bla'
    $Result = $sqlCon.Execute($Query)

        $sqlCon2 = ObjCreate('ADODB.Connection')
        $sqlCon2.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
        $Query2 = 'Select Bla Bla From Bla Where bla=' & $Result.GetString
        $sqlCon2.Execute($Query2)

    TCPSend($sSocket[$x], 'Player ' & $sFilter[2] & ' Has Been Banned!')
EndFunc

Func _Ban()
    $sqlCon = ObjCreate('ADODB.Connection')

    $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
    $Query = 'Select Bla Bla From Bla where bla=bla'
    $Result = $sqlCon.Execute($Query)
    $sqlCon.Close 

        $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
        $Query = 'Select Bla Bla From Bla Where bla=' & $Result.GetString
        $sqlCon.Execute($Query)
        $sqlCon.Close 
        $sqlCon = 0

    TCPSend($sSocket[$x], 'Player ' & $sFilter[2] & ' Has Been Banned!')
EndFunc

And here is another way in case you use the same user/password for both SQL queries

Func _Ban()
    $sqlCon = ObjCreate('ADODB.Connection')

    $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
    $Query = 'Select Bla Bla From Bla where bla=bla'
    $Result = $sqlCon.Execute($Query)

        $Query = 'Select Bla Bla From Bla Where bla=' & $Result.GetString
        $sqlCon.Execute($Query)
        $sqlCon.Close 
        $sqlCon = 0

    TCPSend($sSocket[$x], 'Player ' & $sFilter[2] & ' Has Been Banned!')
EndFunc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here are two possible way how to do it:

Func _Ban()
    $sqlCon = ObjCreate('ADODB.Connection')
    $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
    $Query = 'Select Bla Bla From Bla where bla=bla'
    $Result = $sqlCon.Execute($Query)

        $sqlCon2 = ObjCreate('ADODB.Connection')
        $sqlCon2.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
        $Query2 = 'Select Bla Bla From Bla Where bla=' & $Result.GetString
        $sqlCon2.Execute($Query2)

    TCPSend($sSocket[$x], 'Player ' & $sFilter[2] & ' Has Been Banned!')
EndFunc

Func _Ban()
    $sqlCon = ObjCreate('ADODB.Connection')

    $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
    $Query = 'Select Bla Bla From Bla where bla=bla'
    $Result = $sqlCon.Execute($Query)
    $sqlCon.Close 

        $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
        $Query = 'Select Bla Bla From Bla Where bla=' & $Result.GetString
        $sqlCon.Execute($Query)
        $sqlCon.Close 
        $sqlCon = 0

    TCPSend($sSocket[$x], 'Player ' & $sFilter[2] & ' Has Been Banned!')
EndFunc

And here is another way in case you use the same user/password for both SQL queries

Func _Ban()
    $sqlCon = ObjCreate('ADODB.Connection')

    $sqlCon.Open('DRIVER={SQL Server};SERVER=' & $Server & ';DATABASE=Character;UID=' & $User & ';PWD=' & $Pass & ';')
    $Query = 'Select Bla Bla From Bla where bla=bla'
    $Result = $sqlCon.Execute($Query)

        $Query = 'Select Bla Bla From Bla Where bla=' & $Result.GetString
        $sqlCon.Execute($Query)
        $sqlCon.Close 
        $sqlCon = 0

    TCPSend($sSocket[$x], 'Player ' & $sFilter[2] & ' Has Been Banned!')
EndFunc

Still doesn't work any of them above. You have to store the $Result.GetString into a new variable to keep its value during the next sql connection. But for some reason it doesn't update the sql result like its suppose to (its not my querys). Even when I pass off the result to another function. It still doesn't update the result. This is weird... Edited by Warmonger

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Solved! The query results had to be stored into a new variable else it wont hold its value, then you must trim it.

The Problem

Select user_no From [USER_CHARACTER] Where character_name = 'Warmonger
' <-- Trailing Apostrophe On New Line

The Fix

$User_No = StringTrimRight($Result.GetString, 1)
Edited by Warmonger

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