This is giving me a headache....

Results 1 to 2 of 2

Thread: This is giving me a headache....

  1. #1
    Nurice Guest

    Default This is giving me a headache....

    I am trying to run a registration page. No matter what I try, this error is generated. <BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80004005&#039 <BR><BR>[Microsoft][ODBC Microsoft Access 97 Driver] Syntax error in INSERT INTO statement. <BR><BR>/hogwarts/AddUser.asp, line 34 <BR><BR>The code goes a little something like this....<BR><BR>&#060;% <BR> dim objConn<BR> set objConn = Server.CreateObject("ADODB.Connection")<BR> objConn.ConnectionString = "DSN=members"<BR> objConn.Open<BR><BR> dim rsUsers<BR> set rsUsers = Server.CreateObject("ADODB.Recordset")<BR> rsUsers.Open "ID", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable<BR> rsUsers.Filter = "Email = &#039" & Request.Form("Email") & "&#039"<BR> if rsUsers.EOF then<BR> rsUsers.AddNew<BR> end if<BR> dim stryear<BR> rsUsers("Firstname") = Request.Form("Firstname")<BR> rsUsers("Surname") = Request.Form("Surname")<BR> rsUsers("Name") = Request.Form("Firstname") & " " & Request.Form("Surname")<BR> rsUsers("Email") = Request.Form("Email")<BR> rsUsers("Password") = Request.Form("password")<BR> rsUsers("Gender") = Request.Form("Gender")<BR> rsUsers("Bday") = Request.Form("Bday")<BR> rsUsers("Lastlog") = Now<BR> rsUsers("Level") = 0<BR> stryear = CInt(rsUsers("Level")/10)<BR> rsUsers("Year") = stryear<BR> rsUsers("House") = Null<BR> rsUsers("Active") = True<BR> If rsUsers("Gender") = Witch then<BR> rsUsers("Dorm") = rsUsers("Dorm") + 10<BR> else<BR> rsUsers("Dorm") = rsUsers ("Dorm") + 20<BR> end if<BR> rsUsers("Status") = 100<BR>==&#062; rsUsers.Update<BR> Here is the problem- I am not an expert databaser yet. help me out if you can!<BR> <BR> dim strName, value<BR> for each sField in rsUsers.Fields<BR> strName = sField.Name<BR> value = sField.value<BR> Session(strName) = value<BR> next<BR> Session("bValidUser") = True<BR> rsUsers.Close<BR> Set rsUsers = Nothing<BR>%&#062;<BR><BR>Thanx so much.

  2. #2
    Join Date
    Dec 1969

    Default RE: This is giving me a headache....

    I see several POTENTIAL problem spots in that code. But I can&#039t tell which of them (if even any that I suspect!) is causing the problem.<BR><BR>In this line, is the field "Bday" a DATE field in the DB? If so, how do you ensure that the user typed in a valid date on the form???<BR>&nbsp;&nbsp;&nbsp;&nbsp;rsUsers("Bday") = Request.Form("Bday")<BR><BR>In these lines, you never gave a value to the "Dorm" field, so how can you add 10 or 20 to it???<BR>&nbsp;&nbsp;&nbsp;&nbsp;If rsUsers("Gender") = Witch then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;rsUsers("Dorm") = rsUsers("Dorm") + 10<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsUsers("Dorm" ) = rsUsers ("Dorm") + 20<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if<BR><BR>In this line, "Status" *might* be a reserved word in SQL, so it couldn&#039t be used as a field name:<BR>&nbsp;&nbsp;&nbsp;&nbsp;rsUsers("Status") = 100<BR><BR><BR>I think the best way to figure out the problem is to add only 2 or 3 fields at a time, using CONSTANTS instead of stuff pulled from a form, until the error suddenly appears.<BR><BR>That is, start out with just<BR>&nbsp;&nbsp;&nbsp;&nbsp;rsUsers("Firstname ") = "John" <BR>&nbsp;&nbsp;&nbsp;&nbsp;rsUsers("Surname") = "Doe"<BR>&nbsp;&nbsp;&nbsp;&nbsp;rsUsers("Name ") = "John" & " " & "Doe"<BR>&nbsp;&nbsp;&nbsp;&nbsp;rsUsers.Update<BR ><BR>If that works, add a couple of more fields. Keep going, a couple at a time, until you find the problem. It&#039s called "debugging", and all programmers have to learn how to do it, eventually.<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts