469,950 Members | 2,363 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Urgent! : Adding record to database!

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

here is the code to the asp page that adds data to the access database!

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <%
  5. Dim recordsaffected
  6.  
  7. set conn=Server.CreateObject("ADODB.Connection")
  8. conn.Provider="Microsoft.Jet.OLEDB.4.0"
  9. conn.Open "C:\Inetpub\wwwroot\final\database.mdb"
  10.  
  11. set recordsaffected=Server.CreateObject("ADODB.Recordset")
  12.  
  13. location=Request.Form("location")
  14. module=Request.Form("module")
  15. submodule=Request.Form("submodule")
  16. problemday=Request.Form("problemday")
  17. problemmonth=Request.Form("problemmonth")
  18. problemyear=Request.Form("problemyear")
  19. name=Request.Form("name")
  20. problemdescription=Request.Form("problemdescription")
  21.  
  22. on error resume next
  23. sql=" SELECT * FROM probdatabase"
  24.  
  25.  
  26. conn.Execute sql,recordsaffected
  27. recordsaffected.AddNew
  28. recordsaffected.fields("location")=location
  29. recordsaffected.fields("module")=module
  30. recordsaffected.fields("submodule")=submodule
  31. recordsaffected.fields("problemday")=problemday
  32. recordsaffected.fields("problemmonth")=problemmonth
  33. recordsaffected.fields("problemyear")=problemyear
  34. recordsaffected.fields("name")=name
  35. recordsaffected.fields("problemdescription")=problemdescription
  36. recordsaffected.update
  37.  
  38.  
  39.  
  40. if err<>0 then
  41. Response.Write(Err.Description)
  42. else 
  43. Response.Write("Record Added")
  44. end if
  45. conn.close
  46. recordsaffected.close
  47. Set recordsaffected = Nothing
  48. %>
  49.  
  50. </body>
  51. </html>
the problem i am facing is that it displays "OBJECT REQUIRED" after submiting the form... if I comment out the following
Expand|Select|Wrap|Line Numbers
  1. 'recordsaffected.AddNew
  2. 'recordsaffected.fields("location")=location
  3. 'recordsaffected.fields("module")=module
  4. 'recordsaffected.fields("submodule")=submodule
  5. 'recordsaffected.fields("problemday")=problemday
  6. 'recordsaffected.fields("problemmonth")=problemmonth
  7. 'recordsaffected.fields("problemyear")=problemyear
  8. 'recordsaffected.fields("name")=name
  9. 'recordsaffected.fields("problemdescription")=problemdescription
  10. 'recordsaffected.update
it displays record added... but nothing happens.. even if a single line from the above is left uncommented it displays "OBJECT REQUIRED'

PLZ HELP!!! gotta complete this task in 2 days...
Jul 5 '07 #1
1 1138
jhardman
3,406 Expert 2GB
try replacing the conn.execute line with
Expand|Select|Wrap|Line Numbers
  1. recordsaffected.open sql, conn
This is how I write it, does the same thing, and I don't get that error.

Let me know if this helps.

Jared
Jul 5 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.