siblight
asked on
CANT UPDATE Record Using ASP
Hi
I am trying to update a record in a databse but it is not working.
I know its not a permissions problem because i can save / update records in other tables, which only have one record. When i try and update a specific record i get no update permissions.
Can anyone help?
I am trying to update a record in a databse but it is not working.
I know its not a permissions problem because i can save / update records in other tables, which only have one record. When i try and update a specific record i get no update permissions.
Can anyone help?
<%
no=request.querystring("PAGEID")
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "g:/inetpub/wwwroot/intranet/shared/setup/site.mdb"
set rs = Server.CreateObject("ADODB.recordset")
sql="UPDATE customers SET "
sql=sql & "content='" & Request.Form("content") & "'"
sql=sql & " WHERE ID='" & no & "'"
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.write("Student Page Saved!<BR>")
end if
conn.close
%>
ASKER
I when i submit my form i only get a blank page
Now use this and say me what you are getting.
<%
no=request.querystring("PA GEID")
set conn=Server.CreateObject(" ADODB.Conn ection")
conn.Provider="Microsoft.J et.OLEDB.4 .0"
conn.Open "g:/inetpub/wwwroot/intran et/shared/ setup/site .mdb"
set rs = Server.CreateObject("ADODB .recordset ")
Response.write "PageID:<" & no & ">"
If no <> "" Then
sql="UPDATE customers SET "
sql=sql & "content='" & Request.Form("content") & "'"
sql=sql & " WHERE ID= " & no & " "
on error resume next
conn.Execute sql
if err<>0 then
response.write("Error:" & err.Description)
else
response.write("Student Page Saved!<BR>")
end if
End If
conn.close
%>
<%
no=request.querystring("PA
set conn=Server.CreateObject("
conn.Provider="Microsoft.J
conn.Open "g:/inetpub/wwwroot/intran
set rs = Server.CreateObject("ADODB
Response.write "PageID:<" & no & ">"
If no <> "" Then
sql="UPDATE customers SET "
sql=sql & "content='" & Request.Form("content") & "'"
sql=sql & " WHERE ID= " & no & " "
on error resume next
conn.Execute sql
if err<>0 then
response.write("Error:" & err.Description)
else
response.write("Student Page Saved!<BR>")
end if
End If
conn.close
%>
ASKER
sorry i actually get this message:
Error:Syntax error (missing operator) in query expression 'ID=
Error:Syntax error (missing operator) in query expression 'ID=
Okay now use this one and say me the ouput
<%
no=request("PAGEID")
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "g:/inetpub/wwwroot/intranet/shared/setup/site.mdb"
set rs = Server.CreateObject("ADODB.recordset")
Response.write "PageID:>>" & no & "<< <br>"
If no <> "" Then
sql="UPDATE customers SET "
sql=sql & "content='" & Request.Form("content") & "'"
sql=sql & " WHERE ID= '" & no & "' "
on error resume next
conn.Execute sql
if err<>0 then
response.write("Error:" & err.Description)
else
response.write("Student Page Saved!<BR>")
end if
End If
conn.close
%>
ASKER
PageID:>><<
Okay so it means that the no variable which you are creating from the below line
no=request.querystring("PA GEID") is blank
so better change it to below line and try
no=request.Form("PAGEID")
no=request.querystring("PA
so better change it to below line and try
no=request.Form("PAGEID")
Or Else just use this and let me know. Final stuff
<%
no=Request("PAGEID")
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "g:/inetpub/wwwroot/intranet/shared/setup/site.mdb"
set rs = Server.CreateObject("ADODB.recordset")
sql="UPDATE customers SET "
sql=sql & "content='" & Request.Form("content") & "'"
sql=sql & " WHERE ID= '" & no & "' "
on error resume next
conn.Execute sql
if err<>0 then
response.write("Error:" & err.Description)
else
response.write("Student Page Saved!<BR>")
end if
conn.close
%>
ASKER
With that last portion of code i got this message:
Error:Data type mismatch in criteria expression.
So, if your ID column in table is numeric then use the below line and remove single quotes from it.
Change
sql=sql & " WHERE ID= '" & no & "' "
with
sql=sql & " WHERE ID= " & no & " "
Change
sql=sql & " WHERE ID= '" & no & "' "
with
sql=sql & " WHERE ID= " & no & " "
ASKER
The final message i get is:
I think this is a permissions error, but what i dont understand is i can write to other tables in this mdb with no problems
I think this is a permissions error, but what i dont understand is i can write to other tables in this mdb with no problems
Error:Operation must use an updateable query.
its not a permission error. Use this code below and you problem should be solved.
<%
no=Request("PAGEID")
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
Conn.Mode = 3
conn.Open "g:/inetpub/wwwroot/intranet/shared/setup/site.mdb"
set rs = Server.CreateObject("ADODB.recordset")
sql="UPDATE customers SET "
sql=sql & "content='" & Request.Form("content") & "'"
sql=sql & " WHERE ID= " & no & " "
on error resume next
conn.Execute sql
if err<>0 then
response.write("Error:" & err.Description)
else
response.write("Student Page Saved!<BR>")
end if
conn.close
%>
And finally still if you are getting the same thing then do this settings. Running ASP scripts that does insert/update query's on an Access DB.
- Go to your Control Panel
- Administrative Tools > IIS
- Expand the folder of your site/application
- Right-click the DB folder (just the folder where your .mdb is in)
- Go to "All-tasks" and click "Permissions Wizard"
- Click "Next" for 4 times, without changing anything and finish
- Go to your Control Panel
- Administrative Tools > IIS
- Expand the folder of your site/application
- Right-click the DB folder (just the folder where your .mdb is in)
- Go to "All-tasks" and click "Permissions Wizard"
- Click "Next" for 4 times, without changing anything and finish
ASKER
Thanks! That code didn't help i still get:
Error:Operation must use an updateable query.
I will get my network manager to try and follow the steps in IIS
Error:Operation must use an updateable query.
I will get my network manager to try and follow the steps in IIS
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window