For Programmers: Free Programming Magazines  


Home > Archive > ASP > April 2007 > Simple ASP MYSQL question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Simple ASP MYSQL question
Lawrence

2007-04-30, 6:56 pm

Hey

I have successfully been able to read from a MYSQL database using
this:

set rs = conn.Execute("SELECT Password FROM UserTable WHERE Username =
'" & entuser & "' AND Password = '" & entpass & "'")

Do while not rs.eof ' Do until it reaches end of db
actualpass = rs("Password")
rs.MoveNext ' Next record
loop


But I now want to be able to add new records to tables, I used this
code, but it does not seem to be able to work, any ideas?

set rs = conn.Execute("INSERT INTO UserTable SET Username = '" &
username & "' AND Password = '" & username & "' AND FirstName = '" &
username & "' AND LastName = '" & username & "' AND Email = '" &
username & "' AND confirm = 0 AND confstring = '" & passconf & "'")

Evertjan.

2007-04-30, 6:56 pm

Lawrence wrote on 30 apr 2007 in microsoft.public.inetserver.asp.general:

> set rs = conn.Execute("INSERT INTO UserTable SET Username = '" &
> username & "' AND Password = '" & username & "' AND FirstName = '" &
> username & "' AND LastName = '" & username & "' AND Email = '" &
> username & "' AND confirm = 0 AND confstring = '" & passconf & "'")
>


I am not a mySql specialist, but the AND's seem faulty.

Try something like:

SQL="INSERT INTO UserTable (Password , FirstName , LastName )"&_
"VALUES ('" & pw & "','" & fn & "','" & ln & "')"
response.write SQL
response.end
' remark these 2 lines above when you are satisfied with the result
set rs = conn.Execute(SQL)

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com