Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Into Problem Error

Status
Not open for further replies.

amal1973

Technical User
Jul 31, 2001
131
0
0
US
I created this Registration Form , its little primitive , but I am having problems with the insert into statement , I tried every thing , appreciate any help

<HTML><head>
<TITLE>New User Registration</TITLE>


<FORM action = &quot;Register.asp&quot; method=&quot;post&quot; id=form1 name=form1
LANGUAGE=javascript onsubmit=&quot;return form1_onsubmit()&quot;>

First Name
<INPUT type=text NAME=firstname VALUE=&quot;&quot; SIZE=25>

Last Name
<INPUT type=text NAME=lastname VALUE=&quot;&quot; SIZE=25>

User Name
<INPUT type=text NAME=userid VALUE=&quot;&quot; SIZE=15>

Password
<INPUT TYPE=PASSWORD NAME=password VALUE=&quot;&quot; SIZE=15>

<INPUT type=&quot;submit&quot; value=&quot;Submit&quot; id=submit1 name=submit1>

</FORM></BODY></HTML>

<%@ Language=VBScript %>
<HTML><HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
</HEAD>
<BODY>

<%

Dim sSQL,conn,rs
Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
set rs = server.CreateObject(&quot;ADODB.Recordset&quot;)

'DSN less connection
conn.Provider = &quot;Microsoft.Jet.OLEDB.4.0&quot;
conn.ConnectionString = &quot;Data Source=&quot; & Server.MapPath(&quot;login.mdb&quot;)
conn.open


strsql = &quot;Select firstname,lastname from TLogin&quot;
set rs = conn.Execute (strsql)

if (rs.BOF)and (rs.EOF) then

sSQL = &quot;Insert into TLogin (Firstname,lastname,username,password) Values&quot; & &quot;('&quot;& Ucase(Request(&quot;firstname&quot;)) & &quot;', '&quot;& Request(&quot;lastname&quot;) & &quot;', '&quot;& Request(&quot;userid&quot;) & &quot;', '&quot; & Request(&quot;password&quot;) & &quot;');&quot;

conn.Execute sSQL,adCmdText

else

SQL = &quot;Delete * from TLogin where username= '&quot; & Request.Form(&quot;userid&quot;) & &quot;'&quot;
conn.execute(SQL)
end if

sSQL = &quot;Insert into TLogin (Firstname,lastname,username,password) Values&quot; & &quot;('&quot;& Ucase(Request(&quot;firstname&quot;)) & &quot;', '&quot;& Request(&quot;lastname&quot;) & &quot;', '&quot;& Request(&quot;userid&quot;) & &quot;', '&quot; & Request(&quot;password&quot;) & &quot;');&quot;
conn.Execute sSQL,adCmdText

'close the recordset
rs.close
set rs = nothing

'close the connection
conn.close
set conn = nothing

%>

<h2>Your login details have been saved to the database<h2>
<A HREF=&quot;login.asp&quot;>[Click here to go to login page]</A>
</BODY>
</HTML>
 
Might help if you told us the error and which line.
First thing to do with debugging sql statements is write it out and stop the page before you actually execute the statement

sql= &quot;insert into ...
response.write(sql)
response.end

conn.exec....

 
thanks for your fast reply .
this is the error i get .

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

--------------------------------------------------------------------------------

Technical Information (for support personnel)

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/mysampleapp/Register.asp, line 50

 
First thing to do.
In your browser click Tools/Internet Options, select Advanced Tab, scroll down and make sure Show Friendly HTTP messages is DE-selected
Run your page again and then report back here with the real error message

 
Try this

sSQL = &quot;Insert into TLogin (Firstname,lastname,username,password) Values&quot; & &quot;('&quot;& Ucase(Request(&quot;firstname&quot;)) & &quot;', '&quot;& Request(&quot;lastname&quot;) & &quot;', '&quot;& Request(&quot;userid&quot;) & &quot;', '&quot; & Request(&quot;password&quot;) & &quot;')&quot;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top