...

View Full Version : SQL Query Syntax



doby48
12-20-2011, 03:20 PM
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?



<%
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

Old Pedant
12-20-2011, 09:04 PM
Yes, you need the apostrophes around the user name.

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

Example:


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.

doby48
12-21-2011, 04:44 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum