Sign in to follow this  
Followers 0
kpu

Vbs To Auto It Conversion

4 posts in this topic

I'm trying to convert a vbs script for a SQL connection, but can't seem to get the syntax correct. I've used Vaconvert 4.0 and made some minor adjustments.

What it's doing is connecting to a DSN Connection called "SQL Server" and writing some fields to a table.

Here's the VB Code

adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=SQL Server;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM domain_workstations" ,objConnection,adOpenStatic,adLockOptimistic

objRecordset.AddNew
objRecordset("inventory_number") = MyComputer
objRecordset("wks_group") = "Administrators" 
objRecordset("wks_user") = "User"
objRecordset.Update

objRecordset.Close
objConnection.Close

Here's the AutoIt Code:

$adOpenStatic = 3
Const $adLockOptimistic = 3
Const $adUseClient = 3

$objConnection = ObjCreate("ADODB.Connection")
$objRecordset = ObjCreate("ADODB.Recordset")
$objConnection.Open ("DSN=SQL Server;")
$objRecordset.CursorLocation = $adUseClient
$objRecordset.Open ("SELECT * FROM domain_workstations" ,$objConnection,$adOpenStatic,$adLockOptimistic)

$objRecordset.AddNew()
$objRecordset("inventory_number") = @ComputerName
$objRecordset("wks_group") = "Administrators"
$objRecordset("wks_user") = "User"
$objRecordset.Update()
$objRecordset.Close()
$objConnection.Close()

Here's the error code I get from scite:

==> Illegal text at the end of statement (one statement per line).:

$objRecordset("inventory_number") = $strComputer

Invalid characters behind Object assignment !

Any help would greatly be appreciated!

:)

Share this post


Link to post
Share on other sites



$objRecordset("inventory_number") = @ComputerName

Here's the error code I get from scite:

Any help would greatly be appreciated!

:)

Did the statement change during execution from @computername to $strComputer ? :(

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Did the statement change during execution from @computername to $strComputer ? :)

It changed from strComputer to $strComputer. I changed it to @ComputerName

Edited by kpu

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'm trying to convert a vbs script for a SQL connection, but can't seem to get the syntax correct. I've used Vaconvert 4.0 and made some minor adjustments.

What it's doing is connecting to a DSN Connection called "SQL Server" and writing some fields to a table.

Here's the VB Code

adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=SQL Server;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM domain_workstations" ,objConnection,adOpenStatic,adLockOptimistic

objRecordset.AddNew
objRecordset("inventory_number") = MyComputer
objRecordset("wks_group") = "Administrators" 
objRecordset("wks_user") = "User"
objRecordset.Update

objRecordset.Close
objConnection.Close

Here's the AutoIt Code:

$adOpenStatic = 3
Const $adLockOptimistic = 3
Const $adUseClient = 3

$objConnection = ObjCreate("ADODB.Connection")
$objRecordset = ObjCreate("ADODB.Recordset")
$objConnection.Open ("DSN=SQL Server;")
$objRecordset.CursorLocation = $adUseClient
$objRecordset.Open ("SELECT * FROM domain_workstations" ,$objConnection,$adOpenStatic,$adLockOptimistic)

$objRecordset.AddNew()
$objRecordset("inventory_number") = @ComputerName
$objRecordset("wks_group") = "Administrators"
$objRecordset("wks_user") = "User"
$objRecordset.Update()
$objRecordset.Close()
$objConnection.Close()

Here's the error code I get from scite:

Any help would greatly be appreciated!

:D

I get the same error on the first field assignment with something a little different:

$adOpenStatic = 3
Const $adLockOptimistic = 3
Const $adUseClient = 3

$objConnection = ObjCreate("ADODB.Connection")
$objRecordset = ObjCreate("ADODB.Recordset")
$objConnection.Open ("DSN=TELEFORM_DE;")
$objRecordset.CursorLocation = $adUseClient
$objRecordset.Open ("SELECT * FROM CRF_TRACK_MAIN" ,$objConnection,$adOpenStatic,$adLockOptimistic)

$objRecordset.AddNew()
$objRecordset("CENTER_SITE") = "9010"
$objRecordset("SCREEN_ID") = "666"
$objRecordset("SUBJ_INIT") = "ADS"
$objRecordset.Update()
$objRecordset.Close()
$objConnection.Close()

C:\temp\TEST1.AU3 (12) : ==> Illegal text at the end of statement (one statement per line).:

$objRecordset("CENTER_SITE") = "9010"

Invalid characters behind Object assignment !

Edited by BinaryVision

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