|
| |
|
|
51
Posts: 49 Joined: 5/30/2002 From: Status: offline
|
Please Help, this cant be that hard! - 8/6/2003 13:59:34
Can someone please look at this little bit of code here and please tell me why It will not allow me to update a table and give me this little error on my web browswer. Here is the error: INSERT INTO people (first,last,dogsname) VALUES (' none' ,' none' ,' ' )The following errors occurred: yeah, I know no error, but that still is not supposed to be on the screen and yet my table is not updated. Here is the code: <html> <head> <title>Add Record</title> </head> <body> <h2>Add Record to a Database Table</h2> <% on error resume next set conn=Server.CreateObject(" ADODB.Connection" ) conn.provider=" Microsoft.Jet.OLEDB.4.0" conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" )) first=Request.Form(" first" ) last=Request.Form(" last" ) dogs_name=Request.Form(" dogsname" ) sql=" INSERT INTO people (first,last,dogsname) VALUES " sql=sql & " (' " & first & " ' ,' " & last & " ' ,' " & dogsname & " ' )" Response.Write(sql) Set result = onlinedb1.Execute (sql) If onlinedb1.Errors.Count > 0 then Response.Write (" The following errors occurred:<br>" ) For each Error in onlinedb1.Errors Response.Write (" Error #: " & Error.Number & " <br>" ) Response.Write (" Error Description: " & Error.Description & " <br>" ) Next Else Response.Write (" Record insertion was successful!" ) End If conn.close %> </body> </html> Thank you all for your time and any opinion would help.
|
|
|
|
rdouglass
Posts: 9187 From: Biddeford, ME USA Status: offline
|
RE: Please Help, this cant be that hard! - 8/6/2003 14:10:59
Do you allow zero-lenght fields in your DB? Just a quick guess. If not, you' ll need default values for all fields you' re trying to INSERT....
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
51
Posts: 49 Joined: 5/30/2002 From: Status: offline
|
RE: Please Help, this cant be that hard! - 8/6/2003 14:45:56
I am not too familiar with " zero lenth" fields. I am rather new at this. sorry for the confusion.
|
|
|
|
51
Posts: 49 Joined: 5/30/2002 From: Status: offline
|
RE: Please Help, this cant be that hard! - 8/7/2003 13:02:52
I set the property to Allow Zero Length to " YES" but I still get the same error, I believe the sql string is correct, the query will work, but there isnt a query being made. i think it has something to do with the line conn.execute(sql).... Add.asp code: <html> <head> <title>Add DataBase Record</title> </head> <body> <% set conn=Server.CreateObject(" ADODB.Connection" ) conn.Provider=" Microsoft.Jet.OLEDB.4.0" conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" )) set rs = Server.CreateObject(" ADODB.Recordset" ) rs.Open " select * from people" , conn %> <h2>Adding a Record</h2> <form method=" post" action=" new.asp" target=" _blank" > <table bgcolor=" #b0c4de" > <% for each x in rs.Fields if x.name <> " no" then%> <tr> <td><%=x.name%></td> <td><input name=" <%=x.name%>" value=" none" size=" 20" ></td> <% end if next rs.close conn.close %> </tr></table> <br /> <input type=" submit" name=" action" value=" Add Record" > </form> </body> </html> then the new.asp code: <html> <head> <title>Add Record</title> </head> <body> <h2>Add Record to a Database Table</h2> <% on error resume next set conn=Server.CreateObject(" ADODB.Connection" ) conn.provider=" Microsoft.Jet.OLEDB.4.0" conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" )) first=Request.Form(" first" ) last=Request.Form(" last" ) dogsname=Request.Form(" dogsname" ) ' Define table to query and SQL statement START ' sql=" INSERT INTO people (first,last,dogsname) VALUES " sql=sql & " (' " & first & " ' ,' " & last & " ' ,' " & dogsname & " ' )" ' Define table to query and SQL statement END ' ' write the sql to be executed ' Response.Write(sql) conn.execute(sql) ' Set result = conn.Execute(sql) conn.close %> </body> </html> do you know why it isnt sending the query? maybe i should take that " onerror moveNext" out? and maybe it will show me something?
|
|
|
|
rdouglass
Posts: 9187 From: Biddeford, ME USA Status: offline
|
RE: Please Help, this cant be that hard! - 8/7/2003 14:56:07
quote:
<% on error resume next set conn=Server.CreateObject(" ADODB.Connection" ) conn.provider=" Microsoft.Jet.OLEDB.4.0" conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" )) first=Request.Form(" first" ) last=Request.Form(" last" ) dogsname=Request.Form(" dogsname" ) ....... I have 2 questions about this section: 1. If you hardcode first, last, and dogsname; does it now work? 2. If you combine these 2 lines: conn.provider=" Microsoft.Jet.OLEDB.4.0" conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" )) to make 1 line: conn.open(" Microsoft.Jet.OLEDB.4.0;Data Source =" & server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" )) does that have any effect? When you do those two things, what SQL response.writes?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
51
Posts: 49 Joined: 5/30/2002 From: Status: offline
|
RE: Please Help, this cant be that hard! - 8/7/2003 15:29:12
here is the error when I take out the " on error" line Add Record to a Database Table INSERT INTO people (first,last,dogsname) VALUES (' test' ,' none' ,' none' ) Microsoft JET Database Engine error ' 80040e14' Syntax error in INSERT INTO statement. /ALD/testasp/puntin/new.asp, line 28
|
|
|
|
51
Posts: 49 Joined: 5/30/2002 From: Status: offline
|
RE: Please Help, this cant be that hard! - 8/7/2003 15:36:02
When I combine these 2 lines: conn.provider=" Microsoft.Jet.OLEDB.4.0" conn.open(server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" )) to make 1 line: conn.open(" Microsoft.Jet.OLEDB.4.0;Data Source =" & server.mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" )) This Error occured: Add Record to a Database Table Microsoft OLE DB Provider for ODBC Drivers error ' 80004005' [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified /ALD/testasp/puntin/new.asp, line 11
|
|
|
|
Long Island Lune
Posts: 2340 Joined: 6/8/2002 From: New York Status: offline
|
RE: Please Help, this cant be that hard! - 8/7/2003 16:08:49
51, Try: set conn=Server.CreateObject(" ADODB.Connection" ) conn.Open " DBQ=" & Server.Mappath(" /ALD/TESTASP/puntin/onlinedb1.mdb" ) & " ;Driver={Microsoft Access Driver (*.mdb)};"
_____________________________
|
|
|
|
Long Island Lune
Posts: 2340 Joined: 6/8/2002 From: New York Status: offline
|
RE: Please Help, this cant be that hard! - 8/7/2003 16:10:42
51, In your very first post you said UPDATE. But your using INSERT. Insert does not UPDATE, it ADDS a new record. Just so I understand - do you want to UPDATE a record or ADD a new one?
_____________________________
|
|
|
|
51
Posts: 49 Joined: 5/30/2002 From: Status: offline
|
RE: Please Help, this cant be that hard! - 8/7/2003 16:22:28
It would ADD, Sorry for the confusion, and I am still getting the error: Add Record to a Database Table INSERT INTO people (first,last,dogsname) VALUES (' test' ,' test' ,' test' ) Microsoft OLE DB Provider for ODBC Drivers error ' 80004005' [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query. /ALD/testasp/puntin/new.asp, line 27 here is line 27 conn.execute(sql) im so lost..... :(
|
|
|
|
51
Posts: 49 Joined: 5/30/2002 From: Status: offline
|
RE: Please Help, this cant be that hard! - 8/8/2003 7:18:20
Yes, I know that the connection works as expected. Just can not insert new records for some reason, I know its something simple.
|
|
|
|
51
Posts: 49 Joined: 5/30/2002 From: Status: offline
|
RE: Please Help, this cant be that hard! - 8/13/2003 14:45:50
I feel so dumb, yes it was a permission issue, thank you guys for all you help.
|
|
|
|
Long Island Lune
Posts: 2340 Joined: 6/8/2002 From: New York Status: offline
|
RE: Please Help, this cant be that hard! - 8/13/2003 16:20:12
Congrat's
_____________________________
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|