andpandpudpie Posted November 30, 2011 Share Posted November 30, 2011 (edited) Hi Everyone, Apologies if I've posted my question in the wrong topic forum but am hoping to try and get help converting a VBscript i have (which connects to an SQL database and runs an SQL statement) and making it work with Autoit script. Please see below the visual basic function for the SQL database connection:- Private Function GetDatabaseValue1(sHost,sServiceName,sUsername,sPassword,sPortNumber,sSQLCmd1) Dim sConn,oRecordSet On Error Resume Next 'SID was SERVICE_NAME ' Create a database connection to the server sConn = "Driver={Microsoft ODBC for Oracle}; " & _ "CONNECTSTRING=(DESCRIPTION=" & _ "(ADDRESS=(PROTOCOL=TCP)" & _ "(HOST="&sHost&")(PORT="&sPortNumber&"))" & _ "(CONNECT_DATA=(SID="&sServiceName&"))); uid="&sUsername&";pwd="&sPassword&";" oConn.Open sConn '* AFTER ESTABLISHING CONNECTION TO DATABASE EXECUTE sSQLCmd1 (SQL STATEMENT) Set oRecordSet = oConn.Execute(sSQLCmd1) If oRecordSet.BOF and oRecordSet.EOF then oRecordSet.Close set oRecordSet=Nothing iRetVal1 = XL_DISPATCH_FAIL GetDatabaseValue1=Err.Description Exit Function End If oRecordSet.MoveFirst Do until oRecordSet.EOF For Each oElement In oRecordSet.Fields sData1= oElement.value & "," Next 'get rid of the last ',' sData1= left (sData1,len(sData1)-1) sData1=sData1 & vbCrLf oRecordSet.MoveNext Loop 'get rid of the last 'vbCrLf' sData1= left (sData1,len(sData1)-2) GetDatabaseValue1=sData1 oRecordSet.Close Set oRecordSet=Nothing oConn.Close End Function Please see below the sub procedure which contains the SQL statment that runs against the above function:- Option Explicit Dim oConn, oFileSystem, oElement, sSQLCmd1, sData1 Sub Main() sSQLCmd1="select XXXXXXXX from XXXXXXXX where XXXXXXXX = XXXXXXXX" iRetVal1=GetDatabaseValue1("XXXXXXXX","XXXXXXXX","XXXXXXXX","XXXXXXXX","XXXXXXXX",sSQLCmd1) '* SET THE VBSCRIPT DATABASE CONNECTION Set oConn = Createobject("ADODB.Connection") Set oFileSystem = Createobject("Scripting.FileSystemObject") Msgbox "Result = " & iRetVal1,vbInformation,"VBscript Execution Complete" End Sub Main() I have also attached the VBscript as a text file. Please can anyone out there help me convert my VBscript to AutoIt script? Any help at this present moment would be greatly appreciated Many Thanks Kind Regards Edited November 30, 2011 by andpandpudpie Link to comment Share on other sites More sharing options...
Xenobiologist Posted November 30, 2011 Share Posted November 30, 2011 Have at look here : Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times 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