I am trying to assign the results of a a SQL select statement to a variable, but the result is always blank ie it appears no value is returned.
I am only a casual vbscripter and thought someone could assist?
Below is the code I am using, which at the moment I would be happy to have the returned value displayed in a messagebox. BTW, the SQL statement works when used in Query Analyser.
Thanks in advance heros.
Dim conn, orecordset
Dim sop_number,agency,message,selectSQL
sop_number= cstr(wscript.arguments(0))
agency= cstr(wscript.arguments(1))
Set conn = createobject("ADODB.Connection"
conn.open "dsn=heat-sdg;uid=sa;pwd=benice;database=SDG"
SelectSQL= "select filepath from filetable where sop_number ='" & trim(sop_number) & "' and agency='" & trim(agency) & "'"
Set oRecordSet = CreateObject("ADODB.Recordset"
oRecordSet.Open SelectSQL, Conn
If oRecordSet.RecordCount =1 Then
message.Value = oRecordSet("filepath".Value
End If
oRecordSet.Close
Conn.Close
Set oRecordSet = Nothing
Set Conn = Nothing
msgbox"The value of message is: " & message
I am only a casual vbscripter and thought someone could assist?
Below is the code I am using, which at the moment I would be happy to have the returned value displayed in a messagebox. BTW, the SQL statement works when used in Query Analyser.
Thanks in advance heros.
Dim conn, orecordset
Dim sop_number,agency,message,selectSQL
sop_number= cstr(wscript.arguments(0))
agency= cstr(wscript.arguments(1))
Set conn = createobject("ADODB.Connection"
conn.open "dsn=heat-sdg;uid=sa;pwd=benice;database=SDG"
SelectSQL= "select filepath from filetable where sop_number ='" & trim(sop_number) & "' and agency='" & trim(agency) & "'"
Set oRecordSet = CreateObject("ADODB.Recordset"
oRecordSet.Open SelectSQL, Conn
If oRecordSet.RecordCount =1 Then
message.Value = oRecordSet("filepath".Value
End If
oRecordSet.Close
Conn.Close
Set oRecordSet = Nothing
Set Conn = Nothing
msgbox"The value of message is: " & message