Visual Basic Script
The Visual Basic script can be found at the location
.\Example Projects\Automation\VBScript\MsAccess\ CreateAccountAccess.vbs
relative to the UMRA Console program directory.
The following listing shows the complete script. Note that the script is kept as simple as possible to make it easier to understand. More error handling should be added to the script in operational environments.
Dim adoConn, adoRS
Set adoConn = CreateObject("ADODB.Connection")
Set adoRS = CreateObject("ADODB.Recordset")
adoConn.Provider = "Microsoft.Jet.OLEDB.4.0"
adoConn.Open "FirstLastNames.mdb"
Set adoRS.ActiveConnection = adoConn
adoRS.Open "SELECT * FROM FirstLastNamesTable"
Dim Umra, Username, UserPassword
Set Umra = CreateObject("UmraCom.Umra")
RetVal = Umra.Connect("AMAZONE", 56814)
While adoRS.EOF = False
Umra.SetVariableText "%Firstname%", adoRS("FirstName")
Umra.SetVariableText "%LastName%", adoRS("LastName")
RetVal=Umra.ExecuteProjectScript("CreateAccount")
RetVal=Umra.GetVariableText("%Username%", Username)
RetVal=Umra.GetVariableText("%Password%", UserPassword)
wscript.echo "User created: " & Username & " - " & UserPassword
adoRS.MoveNext
Wend
If RetVal = 0 Then
WScript.Echo "Project executed successfully, code: " & RetVal
Else
WScript.Echo "Project execution failed, code: " & RetVal
End If
In the next section, parts of the scripts are shown with some comments for each section.
|