473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Update and Delete

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

Apr 26 '07 #1
2 2794

"Brett_A" <br********@gmail.comwrote in message
news:11**********************@n35g2000prd.googlegr oups.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
Apr 26 '07 #2
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" <br********@gmail.comwrote in message news:11**********************@n35g2000prd.googlegr oups.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")
%>

Apr 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
4
by: Jonathan Upright | last post by:
Greetings to anyone who can help: I'm using WebMatrix to make ASP.NET pages, and I chose the "Editable DataGrid" at the project selector screen. As you may know, it defaults to the Microsoft...
4
by: drakuu | last post by:
Hello there, I have DataGrid with some records and I would like to edit it right in the datagrid using the built in commands. I can't figure out a way to pass to the SQL query the record ID...
7
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
10
by: Ivan | last post by:
Hi to all !!! I have one stored procedure that update and delete rows in differents tables, but when I try of delete of the main table this show problems with primary and foreign key. I DROP...
13
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I am using VS2005. I created a Windows Appication project. Inside the Server Explorer, I created a new SQLExpress database, and then created a new table. I added the rows, making my first row an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.