[quoted text, click to view] > "Ryan Trudelle-Schwarz" <news@mamanze.com> wrote
>
>>> I just have a function that does some sql stuff. When I run this I
>>> get
>>> an
>>> object expected error on the <input type="button"... line
>>> Does anyone have a suggestion?
>>> This is written for IE only - it's an internal tool...
>>> Here is the code that fails.
>>> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
>>> <html>
>>> <head>
>>> <title>tool</title>
>>> <%
>>> Function flushActivity
>>> Dim oConn, cSql
>>> cSql= "UPDATE activity SET Content= '' WHERE Class_Number = 2"
>>> set oConn = Server.CreateObject("ADODB.connection")
>>> oConn.Open Session("DSN")
>>> oConn.Execute(cSql)
>>> Response.write("executing: " & cSql & "<br>")
>>> oConn.Close
>>> set oConn = nothing
>>> End Function
>>> %>
>>> </head>
>>> <body>
>>> <form>
>>> <input type="button" value="Flush Activity"
>>> onclick="flushActivity()">
>>> </form>
>>> </body>
>>> </html>
>> Do you want this to execute on the client or the server? Right now,
>> your script block is server code while your button's onclick handler
>> is client side.
>>
> Interesting... the function accesses a sql database, which is server
> side. I assumed that the function was client side. whats the best way
> to go about this, given that the db is on the server?
>
> (thanks SO much in advance!)
IIRC, the easiest method is going to be to add a Runat="server" to the button
tag, in which case the button should post back and call the method when clicked.
In case the input type="button" is not wired up to do that, you can use a
<asp:button in its place and get the same functionality (just change the
tag name and change value attribute to text and it should be good).