Yes, in ASP.NET 2.0+, it's ClientScript instad of Page.Register....

Note that ClientScript.RegisterClientScriptBlock != Page.RegisterStartupScript. The equivalent is ClientScript.RegisterStartupScript.

RegisterStartupScript means "execute this as soon as the page loads", while RegisterClientScriptBlock means "here's some new JavaScript. Put it on the page, I might use it later."


Also, move your conn.Close() to the Finally block, not the Catch.


Also also, you need to close your script tag.

"<script type='text/JavaScript'>alert('" & ex.Message & "');</script>"