0
<script language="vbscript">

Function getActivity(ID)
    Option explicit
    Response.Buffer = true
    dim conn, sql, rs,rs1,Action, UserID, strHolder,                
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open Application("Database4_ConnectionString")
    sql = ""
    sql = "Select DateShown, Title, TextBody from Activity where ActID = "& ID
    set rs = Conn.Execute(sql)
    strHolder = rs("TextBody")
    If InStr(strHolder, "</font>") > 0 or InStr(strHolder, "</p>") > 0 or InStr(strHolder, "<br>") > 0 Then
        TextBody = strHolder
    Else
        TextBody = Replace("" & strHolder, chr(13) & chr(10), "<br>")
    End if
End Function
</script>

I tried using this vbscript function in html as follows but it doesn't show the expected output.I want to use the content in Text Body

<div class="modal-body">  
        <h4>Text in a modal</h4>  
        <p>You can add some text here too.</p>
        <p><script type="vbscript">getActivity(216)</script></p>                
    </div> 

Please tell me where did I go wrong.

3
  • It does not show expected output...but what does it show? And what is the expected output?
    – Nilpo
    Sep 5, 2012 at 5:14
  • It does not show anything.I want the content stored in "TextBody" Sep 5, 2012 at 5:30
  • Where are you using TextBody? You appear to be assigning text to the variable, but I cannot see anywhere in the code where you are actually using that variable.
    – freefaller
    Sep 5, 2012 at 7:17

2 Answers 2

1

From the Docs:

If used, the Option Explicit statement must appear in a script before any other statements.

As you didn't see an error message, I assume that there is an On Error Resume Next statement loose in your code or a "Don't bother me with errors" option active in your IE settings. Disable them to be able to find and rectify further bugs.

3
  • What does Option Explicit have to do with any of that?
    – Nilpo
    Sep 5, 2012 at 13:16
  • 1
    @Nilpo The OT's code has "Option Explicit" within a function; that's illegal and has to be corrected (before further possible problems can be tackled). Sep 5, 2012 at 13:37
  • Oh man, I looked right passed that. Good catch.
    – Nilpo
    Sep 5, 2012 at 17:05
0

I'm afraid you won't be able to use an ADODB.Connection in client-side vbscript. You should do this on the server-side (in classic-asp, asp.net or any other server-side scripting language).

Not the answer you're looking for? Browse other questions tagged or ask your own question.