ASP syntax error

Status
Not open for further replies.

unload

Ars Tribunus Militum
1,553
Subscriptor
I am finishing a login page on a site and when a new user goes to create a new account i get an asp syntax error like this:

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/Register.asp, line 25, column 73

the code on line 25 column 73 is this:

sSQL = "Insert into admin (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"& //COLUMN73 IS THE 1ST & TO THE LEFT OF THIS COMMENT
Request("userid") & "', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText

COLUMN 73 IS NOTED Please forgive this newbie for what is probably a basic error.
just so you know this asp is to create a new user account for a site where all usernames and passwords are stored in an access db. all else seems to be fuctioning and if I create the user account manually in access the user can authenticate.

if you need more info let me know. TIA

[This message was edited by unload on January 20, 2002 at 20:57.]
 

unload

Ars Tribunus Militum
1,553
Subscriptor
ok got rid of the syntax errors but it does not write info to the database. It retrieves info from access becuase it authenticates users. but when creating a new one now when submit is clicked it says that the info has been written but no new info shows up in the access table. and the user cannot logon with what appears to be a newly created account.

why would this not write info to db? here is the whole .asp


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

<%

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

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


strsql = "Select firstname,lastname from login"
set rs = conn.Execute (strsql)

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

sSQL = "Insert into admin (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"
Request("userid") & "', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText

else

SQL = "Delete * from login where username= '" & Request.Form("userid") & "'"
conn.execute(SQL)
end if

sSQL = "Insert into login (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"
Request("userid") & "', '" & Request("password") & "')"


'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>
[Click here to go to login page]
</BODY>
</HTML>

any clues??
 

temp

Seniorius Lurkius
44
It's because you don't have a "conn.Execute sSQL" after you define the "insert into login..." statement. I.e.
code:<HR>
Code:
sSQL = "Insert into login (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '" 
Request("userid") & "', '" & Request("password") & "')"<P>'close the recordset
rs.close
should be
code:<HR>
Code:
sSQL = "Insert into login (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '" 
Request("userid") & "', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText<P>'close the recordset
rs.close

/Edit: Fixed small syntax error
 

indigo

Well-known member
5,606
I don't use Access, but I wouldn't think you'd have to ucase your stuff... T-SQL doesn't need it for Like atleast... Oracle does AFAIK though...

Anyways... if I couldn't afford T-SQL I'd just use MySQL... not Access... maybe that's just me though. It could be Access suits your needs best, and you're most comfortable with it... that's cool. Just pointing out that if you want to get into bigger db stuff, MySQL might be something to look at (AFAIK it's ANSI-SQL).

I'm sure you've already thought of that and weighed the costs/benefits yourself already though... just some friendly advice. ;)
 

HitScan

Ars Tribunus Militum
2,523
Subscriptor++
Just pointing out that if you want to get into bigger db stuff, MySQL might be something to look at (AFAIK it's ANSI-SQL).
Unless things have changed drastically recently, MySQL lacks certain features that, well, make a modern RDBMS a modern RDBMS. In my eyes, it's PostreSQL, or a commercial thing. Far too many people choose MySQL just because of that silly GPL :rolleyes:

HitScan
 

unload

Ars Tribunus Militum
1,553
Subscriptor
thx for replies . actually cost is not a concern in fact i htis machine is also a sql2000 server.
this is my first venture into ASP coding so i am usiing access as a back end for this basic config.


"It's because you don't have a "conn.Execute sSQL" after you define the "insert into login..." statement. I.e.
"

thta was in there but i took at out before i posted because i was getting errors associated with that. It was not writing to the db before i took it out. thx again
 

indigo

Well-known member
5,606
I was more referring to having a (near) ANSI-SQL server to work with for learning. Performance and features don't seem to be too high of a priority.

That said, if Postrege is better, and recommended over MySQL, then that's probably the better choice. I just recommended something free and ANSI-SQL compatible (AFAIK) for the learning experience.

unload: I actually find T-SQL (Microsoft SQL Server) rather easy (mostly), and never tried Access. From what I understand, Access is rather limiting in SQL in syntax/features, and then there's the obvious performance concerns.

Query Analyzer and Enterprise Manager just make alot more sense to me than Access too...

I guess the big deal is that I just never really learned how to use Access properly. ;)
 

temp

Seniorius Lurkius
44
[The conn.execute statement] was in there but i took at out before i posted because i was getting errors associated with that. It was not writing to the db before i took it out. thx again

What was the error message? If the SQL statement generated errors, then it probably couldn't execute. And since it couldn't execute it didn't put the account in the database either.

Here's a debugging tip: If you are having trouble with a SQL statement you can put a Response.Write in just before the conn.execute. That way you can take a good look at the SQL and maybe figure out what the problem is. Like this:
code:<HR>
Code:
sSQL = "SELECT * FROM Login"       'SQL statemnt that doesn't work
Response.Write(sSQL)               'Write the SQL statement to screen
Set rsTemp = Conn.Execute(sSQL)    'Execute the SQL Statement
Set rsTemp = Nothing
 
Status
Not open for further replies.