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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server 500 Error

Status
Not open for further replies.

Geee

Programmer
Apr 23, 2001
253
GB
This is driving me insanse. I have a not very complicated form which passes to a page that SHOULD put the form details into the database. I can build up the SQL statement fine, but when I try to execute the statement I get a 500 error. The code for the execute page is...

=======valadduser.asp==========
<%
If Session(&quot;UserLevel&quot;) <> 2 Then Response.Redirect(&quot;default.asp&quot;)
'Check user is logged in as admin

username = Request.Form(&quot;Username&quot;)
password = Request.Form(&quot;password&quot;)
email = Request.Form(&quot;email&quot;)
displayname = Request.Form(&quot;DisplayName&quot;)
Level = Request.Form(&quot;Level&quot;)
'Get form values

Dim DBmcc, dbPath, DBrs

dbPath = server.MapPath(&quot;../data/data.mdb&quot;)
Set DBmcc = Server.CreateObject (&quot;ADODB.Connection&quot;)
DBmcc.Open &quot;PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=&quot; & dbPath
'

SQL=&quot;INSERT INTO Users (Username, Password, email, DisplayName, ULevel) VALUES ('&quot; & username & &quot;', '&quot; & password & &quot;', '&quot; & email & &quot;', '&quot; & displayname & &quot;', &quot;& level & &quot;)&quot;
Response.Write SQL
DBmcc.Execute SQL
'Generate SQL and execute it

DBmcc.Close
set DBmcc = nothing
'Tidy Up

Response.Redirect(&quot;../default.asp&quot;)
'Return user to admin default screen
%>
======================
BUT, if I comment out the DBmcc.Execute SQL line the page compiles properly, and I get a valid SQL statement shown, like...

INSERT INTO Users (Username, Password, Email, DisplayName, Level) Values ('test', 'test', 'test@test.com', 'Test', 1)

Which also executes fine if I cut and paste into an Access Query. This is driving me mad. Does anyone notice anything I don't. Oh and the first 4 fields are text, while the last field is numeric.

Thanks in Advance
G -GTM Solutions, Home of USITE-
-=
 
SQL=&quot;INSERT INTO Users (Username, Password, email, DisplayName, ULevel) VALUES ('&quot; & username & &quot;', '&quot; & password & &quot;', '&quot; & email & &quot;', '&quot; & displayname & &quot;', &quot;& level & &quot;)&quot;

is missing your last closing single tick:

SQL=&quot;INSERT INTO Users (Username, Password, email, DisplayName, ULevel) VALUES ('&quot; & username & &quot;', '&quot; & password & &quot;', '&quot; & email & &quot;', '&quot; & displayname & &quot;', &quot;& level & &quot;')&quot;

but I'm not convinced that would be getting you a 500, <sarcasm>which just happens to be my favorite error in the whole wide world</sarcasm>.

See if that clears it, and post back if not.
penny.gif
penny.gif
 
hey link are you following me, lol

ps... the last tag on that coding, is a numeric field, it doesnt have a ' involved with it at all

SQL=&quot;INSERT INTO Users (Username, Password, email, DisplayName, ULevel) VALUES ('&quot; & username & &quot;', '&quot; & password & &quot;', '&quot; & email & &quot;', '&quot; & displayname & &quot;', &quot;& level & &quot;)&quot;
 
ok i dont know if this is the problem but it may be the reason for the error, i have had a look at a couple of error 500 examples....

you need to make sure the database is updatable by an internet user, do this by locating the database, with the use of my computer, right click, and choose security. Thier needs to be a user in the list called IUSER(blah blah) if not add him.. He must also have read and write access or any alterations you try to make, will not work

Hope thats it
 
True enough. Sorry bout that Gee.

At any rate, 500 error generally denotes some minutia that is nearly impossible to pick out.

Here's what I have done in the past to squash this error:

(1) make sure <%@language=vbscript%> is declared at the top. That has raised this error for me before.

(2) rebuild the page, calling it something else -- piece by piece, testing as you go, until it's back up to full strength and see where you error out (if at all).

I have actually done (2) before and built the page back up character for character EXACTLY the same, and everything worked perfectly. Go figure.

Because as you pointed out, Gee, the page is very simple, and to me, the code looks good.

Let us know.
penny.gif
penny.gif
 
I uploaded my code onto a different server, and managed to generate the following error. The INSERT statement bit is the result of the Response.Write SQL. Any ideas. I removed the last value because it is not really required at this point.

====
INSERT INTO Users (Username, Password, email, DisplayName) VALUES ('1', '1', '1@1.c', '1')

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/roffs/admin/valaddus.asp, line 18
====
G -GTM Solutions, Home of USITE-
-=
 
I now get...

INSERT INTO Users (UName, Pwd) VALUES ('235', '2345')
Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

/roffs/admin/valaddus.asp, line 24



Grrrr -GTM Solutions, Home of USITE-
-=
 
that could be for the reason labeled above about the user permissions, or the fact that you need to use the words

set SQL = etc etc
 
Yes you are write, the second erro was on a live server that I shouldn't really have been using. I have solved the problem. The order of my fields in the INSERT was not the same as the order of the fields in the database. When I changed this everything works great. Personally I can't see how this can make a difference, but ASP is a strange beast...
Thanks none the less.
G -GTM Solutions, Home of USITE-
-=
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top