kpu Posted May 10, 2006 Share Posted May 10, 2006 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! http://www.kpunderground.com Link to comment Share on other sites More sharing options...
Developers Jos Posted May 10, 2006 Developers Share Posted May 10, 2006 $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 More sharing options...
kpu Posted May 10, 2006 Author Share Posted May 10, 2006 (edited) Did the statement change during execution from @computername to $strComputer ? It changed from strComputer to $strComputer. I changed it to @ComputerName Edited May 10, 2006 by kpu http://www.kpunderground.com Link to comment Share on other sites More sharing options...
Guest BinaryVision Posted June 7, 2006 Share Posted June 7, 2006 (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! 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 June 7, 2006 by BinaryVision Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now