| | |
|
Active Server Pages ASP programs help tutorial tutorials routine routines jobs listserve mailinglist bulletin board bulletin boards programming snippet snippets CJWSoft ASPProtect ASPBanner ASPClassifieds
(Advanced)
(Components)
(Database)
(General)
(Vbscript)

|
|
Subject: |
Re: Problem with updating database |
From: |
Harlan |
Date: |
2/25/1999 9:24:55 AM |
IP: |
206.222.20.2 |
Could someone tell me what is wromg with the following code?
-it would have helped if you would have told
us what the error you get is, or problem is.
I've tried to get it work
for several hours and I'm pretty fed up with this... Please help me!
Btw. Sorry that those variables are in finnish. I hope it doesn't bother anyone.
-wow it sure makes it hard to understand ;)
<%
'on error resume next
'NEVER EVER on error resume next unless you are
'200% sure you know what you are doing!!!!
'do error checking instead!
id = Request.form("id")
yritys = Request.form("yritys")
toimiala = Request.form("toimiala")
osoite = Request.form("osoite")
postinumero = Request.form("postinumero")
toimipaikka = Request.form("toimipaikka")
puhelin = Request.form("puhelin")
fax = Request.form("fax")
www=Request.form("www")
email=Request.form("email")
yhteyshenkilo=Request.form("yhteyshenkilo")
'I'm going to assume all these variables are
'being set, and none of them are empty.
'you'll need to validate that both in the
'previous page, and on this one.
'you also need to make sure no one has entered
'a single quote (') into any of the lines.
'if they have you need to replace it with two
'of them so sql doesn't choke on it.
Set Conn = Server.CreateObject("ADODB.Connection")
'you need DSN= and I'm assuming this is an access
'database, if not you need: "DSN=;UID=;PWD="
Conn.Open "DSN=Yritys"
'your way of concatanating is fine, I just
'like they way this looks better ;)
SQLlause = "UPDATE Perus " & _
"SET Yritys='" & yritys & "'," & _
"Toimiala = '" & toimiala & "'," & _
"Osoite = '" & osoite & "'," & _
"Postinumero = '" & postinumero & "'," & _
"Toimipaikka = '" & toimipaikka & "'," & _
"Puhelin = '" & puhelin & "'," & _
"FAX = '" & fax & "'," & _
"WWW = '" & www & "'," & _
"EMail = '" & email & "'," & _
"Yhteyshenkilö ='" & yhteyshenkilo & "' " & _
"WHERE Tunniste=" & id
'this sql statment assumes the datatype for
'all the fields are text except the id field
'is numeric, you will want to double check that.
'you dont' need to return anything with an
'update statement.
Conn.Execute(SQLlause)
'really all I did was add DSN= to the Conn.Open()
if that doesn't do it.. you need to be more
spacific about your problem.
|
Previous Message
|
|

|
|
|
|