Jump to content

Two ADODB.Connection's One Function


Recommended Posts

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
Link to comment
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
Link to comment
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:

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
Link to comment
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
Link to comment
Share on other sites

  • 4 weeks later...

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
Link to comment
Share on other sites

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
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...