Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    24
    Thanks
    3
    Thanked 0 Times in 0 Posts

    SQL Query Syntax

    I can write SQL queries in ASP no problem but I have one that I need to run within Enterprise Manager as it will timeout if I call it from an ASP. Can someone help me with the syntax?

    Code:
    <%
    dim strUserName
    
    strUserName = "isisTraffic" then
    	szStatement = "execute dbo.ap_DeleteDynamicResource '" + strUserName + "'"
    	set conn = createobject("ADODB.Connection")
    	conn.provider = "sqloledb"
    	conn.connectionstring = "data source="& DB &";uid="& UID &";pwd="& PWD &";initial catalog=site_security"
    	conn.open
    	conn.execute(szStatement)
    	conn.close
    	set conn = nothing
    %>
    Is this just as simple as typing in the following? I am guessing I may need single or double quotes around the UserName but not quite sure.
    execute dbo.ap_DeleteDynamicResource strUserName
    Last edited by doby48; 12-20-2011 at 03:22 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    Yes, you need the apostrophes around the user name.

    If the user name itself contains an apostrophe, you need to double it.

    Example:
    Code:
        execute dbo.ap_DeleteDynamicResource 'O''Brien'
    By the way, it would be easy to change the timeout in the ASP code to a larger value.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    doby48 (12-21-2011)

  • #3
    New Coder
    Join Date
    Mar 2011
    Posts
    24
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Perfect, worked as expected. Thank you very much! Normally increasing the timeout for the ASP would have been easy enough but because of the security layer that the responses go through and the timeout values within that layer in addition to IIS this wasnt a feasible option.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •