Jump to content

Vbs To Auto It Conversion


Recommended Posts

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!

:)

Link to comment
Share on other sites

  • Developers

$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 ? :(

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 4 weeks later...
Guest BinaryVision

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