Ok vbscript gurus, this is probably a simple question. This is my first attempt at vbscript. I am querying a database with input from the user, and when the records are returned to the message box, I have a retry button there. If the information that is returned is not what the user is looking for, I want them to be able to hit retry and "rerun" the vbscript. As it stands with the code below - you enter the parameter the first time, records are returned, you click retry and the input box form opens again, you enter your parameter, then it closes without returning anything the second time. If someone could point me in the right direction that would be awesome because I fear I have spent way to much time on this already. Thanks in advance for looking and extending me the understanding I am new at this . I have changed the server name and database name in the example.
________________________________________
Option Explicit
GetInfo()
Dim strInput, strGroup
Dim objCN, strConnection
Dim Result
Set objCN = CreateObject("ADODB.Connection")
strConnection = "Driver={SQL Server};Server=MyServer;Database=MyDatabase;Trusted_Connection=TRUE"
objCN.Open strConnection
If strinput = -1 or strinput = "" then
wscript.quit
End If
Dim strSQLQuery
strSQLQuery = "Select * from dbo.vw_script where responsibility like '%" & strinput & "%'"
Dim objRS
objRS=CreateObject("ADODB.Recordset")
Set objRS = objCN.Execute(strSQLQuery)
WHILE objrs.EOF <> TRUE
'access columns using objRS("column")
strGroup = strGroup & objRS.Fields("name") & " - " & objrs.fields("responsibility") & " - " & objrs.fields("con_type") & vbcrlf
objRS.MoveNext
WEND
Result = MsgBox(strGroup,vbretryCancel,"Information")
If Result = vbRetry then
GetInfo()
End If
objRS.Close
objCN.Close
Function GetInfo()
strinput = inputbox("Enter any part of responsibility", "Enter Information")
End function
________________________________________
Option Explicit
GetInfo()
Dim strInput, strGroup
Dim objCN, strConnection
Dim Result
Set objCN = CreateObject("ADODB.Connection")
strConnection = "Driver={SQL Server};Server=MyServer;Database=MyDatabase;Trusted_Connection=TRUE"
objCN.Open strConnection
If strinput = -1 or strinput = "" then
wscript.quit
End If
Dim strSQLQuery
strSQLQuery = "Select * from dbo.vw_script where responsibility like '%" & strinput & "%'"
Dim objRS
objRS=CreateObject("ADODB.Recordset")
Set objRS = objCN.Execute(strSQLQuery)
WHILE objrs.EOF <> TRUE
'access columns using objRS("column")
strGroup = strGroup & objRS.Fields("name") & " - " & objrs.fields("responsibility") & " - " & objrs.fields("con_type") & vbcrlf
objRS.MoveNext
WEND
Result = MsgBox(strGroup,vbretryCancel,"Information")
If Result = vbRetry then
GetInfo()
End If
objRS.Close
objCN.Close
Function GetInfo()
strinput = inputbox("Enter any part of responsibility", "Enter Information")
End function