Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
SQL Server Newbies
»
Update SQL Statement
11 posts, Page 1 of 2
1
2
»»
Update SQL Statement
Rate Topic
Display Mode
Topic Options
Author
Message
poloarun
poloarun
Posted Tuesday, September 16, 2008 7:25 AM
Grasshopper
Group: General Forum Members
Last Login: Friday, October 24, 2008 3:16 AM
Points: 12,
Visits: 35
I am creating some questions site by ASP, by filling in the answers in a table on SQL 2005 and passing to the next site.
I'm giving the user a kind of tracking (identity), wich the user is passing over from on Question site to the other by Request.Form.
On the first Site the user is filling the name, first name, time and the kind of identity
sql= "INSERT INTO web(first name ,name,identy,time)VALUES('" & first name & "','" & name & "','" & identy & "','" & time & "')"
this works fine!
No I would like to continue with an Update Statement.
sql = Update web Set answer1='" & answer1 & "' where identity ='" & identity &
It gives me just an Internet Error Message: The page can't be shown...
Post #570210
Kyle Neier ,
Kyle Neier ,
Posted Tuesday, September 16, 2008 7:40 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 6:52 AM
Points: 194,
Visits: 1,059
I suspect that your browser is suppressing the real error message. You should look to see if Friendly HTTP Error messages is turned on.
Pertinent to this forum, what you are doing appears to be ripe for SQL injection. One of the basics is to use stored procedures and pass in parameters instead of building the ad-hoc SQL.
There are all sorts of best practices out there regarding ASP and SQL Server development. I strongly suggest that you visit a few of these websites before getting too far down this path.
Kyle
Post #570225
Jack Corbett
Jack Corbett
Posted Tuesday, September 16, 2008 7:40 AM
SSChampion
Group: General Forum Members
Last Login: 2 days ago @ 12:22 PM
Points: 10,571,
Visits: 11,871
If this is actually the line of code:
sql = Update web Set answer1='" & answer1 & "' where identity ='" & identity &
Then it isn't going to work as you do not have an opening double-quote on the string and you are ending the line with the concatenation character.
Beyond that you are leaving yourself open to SQL Injection by using the methods you are using. At the very least you should be using a command object with parameters instead of a straight SQL string.
Jack Corbett
Applications Developer
Don't let the good be the enemy of the best. --
Paul Fleming
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #570226
poloarun
poloarun
Posted Tuesday, September 16, 2008 7:49 AM
Grasshopper
Group: General Forum Members
Last Login: Friday, October 24, 2008 3:16 AM
Points: 12,
Visits: 35
It is obvious, the SQL Satement is wrong,
But I can't yet manage it the right way.
sql = "Update web Set antwort1="' & antwort1 & "' where erkennung='" & erkennung & "'"
It doesnt work too!
Can anybody help my aboout the Update Statement ?
Post #570235
Jack Corbett
Jack Corbett
Posted Tuesday, September 16, 2008 8:05 AM
SSChampion
Group: General Forum Members
Last Login: 2 days ago @ 12:22 PM
Points: 10,571,
Visits: 11,871
Have you viewed the SQL string that is built and verified that it is valid in SSMS? Just a Response.Write(SQL) so you can verify the string is bing built correctly would help. If your table and column names are correct then I can't see anything wrong with SQL Statement.
Jack Corbett
Applications Developer
Don't let the good be the enemy of the best. --
Paul Fleming
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #570248
Kyle Neier ,
Kyle Neier ,
Posted Tuesday, September 16, 2008 8:11 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 6:52 AM
Points: 194,
Visits: 1,059
Look at the quotes after "antwort1="
You have "' and I believe it should be '" .
Post #570256
poloarun
poloarun
Posted Tuesday, September 16, 2008 8:26 AM
Grasshopper
Group: General Forum Members
Last Login: Friday, October 24, 2008 3:16 AM
Points: 12,
Visits: 35
I am trying out:
Actually
sql = "Update web Set answer1='" & answer1 & "' where identity='" & identity & "'"
Gives the error message with
Response.Write (SQL)
Response.End
Update web Set answer11='gerste' where identity=''3597@10P136P12P125''
Wich is not yet working.
Post #570273
Roy Ernest
Roy Ernest
Posted Tuesday, September 16, 2008 8:53 AM
Hall of Fame
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:24 AM
Points: 3,280,
Visits: 6,619
Is this the output of your response.write?
Update web Set answer11='gerste' where identity=''3597@10P136P12P125''
I see double quotes in the identity part. Check the Identity part. Also if I am not mistaken Identity (Your Column Name) is a Keyword. Put a square bracket for IDENTITY.
-Roy
Post #570315
poloarun
poloarun
Posted Wednesday, September 17, 2008 3:10 AM
Grasshopper
Group: General Forum Members
Last Login: Friday, October 24, 2008 3:16 AM
Points: 12,
Visits: 35
identity is just a normal column, not the identifier, I know, it is probalbly not right to use this word as an normal column, since it it reserved as identifier.
I don't know how to make the square brackets.
What would the SQL Statement be ?
Post #570843
poloarun
poloarun
Posted Wednesday, September 17, 2008 3:35 AM
Grasshopper
Group: General Forum Members
Last Login: Friday, October 24, 2008 3:16 AM
Points: 12,
Visits: 35
I found the right SQL Statement.
sql = "Update web Set answer1='" & answer1 & "'" & " where identity=" & identity
Thanks a lot for your replies.
SQL seems to be very delicate.
Post #570860
« Prev Topic
|
Next Topic »
11 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.