Update and Delete

Update and Delete

am 26.04.2007 15:07:33 von Brett_A

Any reason why this code doesn't work? It doesn't generate any errors
but it doesn't update the data.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
on error resume next

'request variables

report_id = Request.querystring ("report_id")
ad_id = Request.querystring ("ad_id")
report_count = Request.querystring ("report_count")

'reduce report count

report_count = report_count - 1

'create connection

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "driver={SQL Server};server=xxxxxxxx"

'delete spam SQL

SQLstmt = "DELETE FROM tbl_reports WHERE report_id=" & report_id & ""

'update spam count SQL

SQLstmt1 = "UPDATE tbl_ads SET "
SQLStmt1 = SQLstmt1 & "report_count='" & report_count & "'"
SQLStmt1 = SQLStmt1 & " WHERE ad_id='" & ad_id & "'"

'execute SQL statements

Conn.execute "SQLstmt"
Conn.execute "SQLstmt1"

'close connection

Conn.close
Set Conn = nothing

'redirction

response.Redirect("alerts.asp")
%>

Re: Update and Delete

am 26.04.2007 15:41:12 von Mike Brind

"Brett_A" wrote in message
news:1177592853.005555.252970@n35g2000prd.googlegroups.com.. .
> Any reason why this code doesn't work? It doesn't generate any errors
> but it doesn't update the data.
>
> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
> <%
> on error resume next
>
> 'request variables
>
> report_id = Request.querystring ("report_id")
> ad_id = Request.querystring ("ad_id")
> report_count = Request.querystring ("report_count")
>
> 'reduce report count
>
> report_count = report_count - 1
>
> 'create connection
>
> Set Conn = Server.CreateObject("ADODB.Connection")
> Conn.open "driver={SQL Server};server=xxxxxxxx"
>
> 'delete spam SQL
>
> SQLstmt = "DELETE FROM tbl_reports WHERE report_id=" & report_id & ""
>
> 'update spam count SQL
>
> SQLstmt1 = "UPDATE tbl_ads SET "
> SQLStmt1 = SQLstmt1 & "report_count='" & report_count & "'"
> SQLStmt1 = SQLStmt1 & " WHERE ad_id='" & ad_id & "'"
>
> 'execute SQL statements
>
> Conn.execute "SQLstmt"
> Conn.execute "SQLstmt1"
>
> 'close connection
>
> Conn.close
> Set Conn = nothing
>
> 'redirction
>
> response.Redirect("alerts.asp")
> %>
>

You have no idea whehter it is producing errors or not (my guess is yes),
because On Error Resume Next will hide them from you. Get rid of that line
first, then try

Conn.execute(SQLstmt)
Conn.execute(SQLstmt1)

If that doesn't work, do

<%
Response.Write SQLstmt : Response.End
%>

to output the SQL to the browser. That way you can check that report_id
contains the value you expect. And do the same for the other statement.

--
Mike Brind

Re: Update and Delete

am 26.04.2007 15:44:07 von Jon Paal

there are no errors because you have "on error resume next"

comment that line of code and you will see the error messages

probably a quoting problem in your sql




"Brett_A" wrote in message news:1177592853.005555.252970@n35g2000prd.googlegroups.com.. .
> Any reason why this code doesn't work? It doesn't generate any errors
> but it doesn't update the data.
>
> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
> <%
> on error resume next
>
> 'request variables
>
> report_id = Request.querystring ("report_id")
> ad_id = Request.querystring ("ad_id")
> report_count = Request.querystring ("report_count")
>
> 'reduce report count
>
> report_count = report_count - 1
>
> 'create connection
>
> Set Conn = Server.CreateObject("ADODB.Connection")
> Conn.open "driver={SQL Server};server=xxxxxxxx"
>
> 'delete spam SQL
>
> SQLstmt = "DELETE FROM tbl_reports WHERE report_id=" & report_id & ""
>
> 'update spam count SQL
>
> SQLstmt1 = "UPDATE tbl_ads SET "
> SQLStmt1 = SQLstmt1 & "report_count='" & report_count & "'"
> SQLStmt1 = SQLStmt1 & " WHERE ad_id='" & ad_id & "'"
>
> 'execute SQL statements
>
> Conn.execute "SQLstmt"
> Conn.execute "SQLstmt1"
>
> 'close connection
>
> Conn.close
> Set Conn = nothing
>
> 'redirction
>
> response.Redirect("alerts.asp")
> %>
>