127 lines
2.2 KiB
Plaintext
127 lines
2.2 KiB
Plaintext
<scriptlet>
|
|
|
|
<Registration
|
|
Description="DataAccessVBS"
|
|
ProgID="DataAccessVBS.Scriptlet"
|
|
Version="1.00"
|
|
ClassID="{f330ec40-2a60-11d2-bec5-204c4f4f5020}"
|
|
>
|
|
</Registration>
|
|
|
|
<implements id=Automation type=Automation>
|
|
<property name=DSN>
|
|
<get/>
|
|
<put/>
|
|
</property>
|
|
<property name=USER>
|
|
<get/>
|
|
<put/>
|
|
</property>
|
|
<property name=PASSWORD>
|
|
<get/>
|
|
<put/>
|
|
</property>
|
|
<property name=SQLString>
|
|
<get/>
|
|
<put/>
|
|
</property>
|
|
<method name=ExecuteQuery>
|
|
</method>
|
|
|
|
</implements>
|
|
|
|
<script language=VBScript>
|
|
|
|
Dim DSN
|
|
DSN="pubs"
|
|
Dim USER
|
|
USER = "sa"
|
|
Dim PASSWORD
|
|
PASSWORD = ""
|
|
Dim SQLString
|
|
Dim Response
|
|
|
|
Function get_DSN()
|
|
get_DSN = DSN
|
|
End function
|
|
|
|
Function put_DSN(newValue)
|
|
DSN = newValue
|
|
End function
|
|
|
|
Function get_USER()
|
|
get_USER = USER
|
|
End function
|
|
|
|
Function put_USER(newValue)
|
|
USER = newValue
|
|
End function
|
|
|
|
Function get_PASSWORD()
|
|
get_PASSWORD = PASSWORD
|
|
End function
|
|
|
|
Function put_PASSWORD(newValue)
|
|
PASSWORD = newValue
|
|
End function
|
|
|
|
Function get_SQLString()
|
|
get_SQLString = SQLString
|
|
End function
|
|
|
|
Function put_SQLString(newValue)
|
|
SQLString = newValue
|
|
End function
|
|
|
|
Function ExecuteQuery()
|
|
Dim objCtx
|
|
Dim objMTS
|
|
Dim oRS, oConn, oFields
|
|
|
|
'Get Object context, pay attention how to get it
|
|
|
|
Set objMTS = CreateObject("MTxAS.AppServer.1")
|
|
Set objCtx = objMTS.GetObjectContext()
|
|
Set Response =objCtx("Response")
|
|
|
|
|
|
On Error resume next
|
|
Set oConn=CreateObject("ADODB.Connection")
|
|
oConn.Open DSN,USER,PASSWORD
|
|
Set oRS=oConn.Execute (SQLString)
|
|
If Err.Number <>0 then
|
|
Response.Write "Err:" &Err.Description
|
|
Execute=false
|
|
Exit function
|
|
end if
|
|
|
|
Response.Write "<TABLE BORDER>"
|
|
while not oRS.EOF
|
|
set oFields=oRs.Fields
|
|
DisplayFields(oFields)
|
|
oRS.MoveNext
|
|
wend
|
|
Response.Write "</TABLE>"
|
|
Execute = true
|
|
|
|
Set Response = Nothing
|
|
Set objMTS = Nothing
|
|
Set objCtx = Nothing
|
|
end function
|
|
|
|
Function DisplayFields( oFields)
|
|
Dim cFields, iField
|
|
cFields=oFields.count
|
|
Response.Write "<TR>"
|
|
for iField=1 to cFields
|
|
Response.Write "<TD>" & oFields(iField) & "</TD>"
|
|
next
|
|
Response.Write "</TR>"
|
|
End function
|
|
|
|
|
|
|
|
</script>
|
|
</scriptlet>
|
|
|