Welcome to WebmasterWorld Guest from 54.145.53.251

Forum Moderators: ocean10000

Message Too Old, No Replies

Problem with updating Access Database using ADO.NET

     
5:07 pm on Mar 28, 2010 (gmt 0)

New User

5+ Year Member

joined:Mar 28, 2010
posts: 3
votes: 0


Hello guys,

I am new in ASP, ADO and IIS, but I find a good tutorial in w3schools. I've started reading the ADO tutorial, because I want to create a simple web page, which is connected to a database.
I will use Access database (.mdb).

So, I've created two web pages. First one is for importing the data in fields, this data should be imported in the Access database. Second one is for importing the data from the fields to the database.

Here the code for the first page:
<html>
<body>

<form method="post" action="input.asp">
<table>
<tr>
<td>&#1053;&#1086;&#1084;&#1077;&#1088; &#1085;&#1072; &#1087;&#1088;&#1086;&#1090;&#1086;&#1082;&#1086;&#1083;&#1072;:</td>
<td><input name="protocolid"></td>
</tr><tr>
<td>&#1053;&#1086;&#1084;&#1077;&#1088; &#1085;&#1072; &#1082;&#1083;&#1080;&#1077;&#1085;&#1090;&#1072;:</td>
<td><input name="clientid"></td>
</tr><tr>
<td>&#1048;&#1084;&#1077; &#1085;&#1072; &#1082;&#1083;&#1080;&#1077;&#1085;&#1090;&#1072;:</td>
<td><input name="clientname"></td>
</tr><tr>
<td>&#1044;&#1072;&#1090;&#1072; &#1085;&#1072; &#1087;&#1086;&#1089;&#1077;&#1097;&#1077;&#1085;&#1080;&#1077;:</td>
<td><input name="date"></td>
</tr><tr>
<td>&#1055;&#1088;&#1086;&#1073;&#1083;&#1077;&#1084;:</td>
<td><input name="problem"></td>
</tr><tr>
<td>&#1056;&#1077;&#1096;&#1077;&#1085;&#1080;&#1077;:</td>
<td><input name="solution"></td>
</tr><tr>
<td>&#1050;&#1086;&#1084;&#1077;&#1085;&#1090;&#1072;&#1088;:</td>
<td><input name="comment"></td>
</tr><tr>
<td>&#1057;&#1083;&#1091;&#1078;&#1080;&#1090;&#1077;&#1083; &#1086;&#1090;&#1080;&#1096;&#1098;&#1083; &#1085;&#1072; &#1084;&#1103;&#1089;&#1090;&#1086;&#1090;&#1086;:</td>
<td><input name="employee"></td>
</tr><tr>
<td>&#1057;&#1083;&#1077;&#1078;&#1080;&#1090;&#1077;&#1083; &#1085;&#1072; &#1092;&#1080;&#1088;&#1084;&#1072;&#1090;&#1072; &#1087;&#1088;&#1080;&#1077;&#1083; &#1087;&#1088;&#1086;&#1090;&#1086;&#1082;&#1086;&#1083;&#1072;:</td>
<td><input name="contactperson"></td>
</tr>
</table>
<br /><br />
<input type="submit" value="&#1044;&#1086;&#1073;&#1072;&#1074;&#1080; &#1087;&#1088;&#1086;&#1090;&#1086;&#1082;&#1086;&#1083;&#1072;">
<input type="reset" value="&#1048;&#1079;&#1095;&#1080;&#1089;&#1090;&#1080;">
</form>

</body>
</html>


Here is the code for the second page:
<html>
<body>

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "D:\Inetpub\wwwroot\Protocols.mdb"

sql="INSERT INTO Protocols(ClientID,ClientName,"
sql=sql & "Date,Problem,Solution,Comment,Employee,ContactPerson)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("clientID") & "',"
sql=sql & "'" & Request.Form("clientName") & "',"
sql=sql & "'" & Request.Form("date") & "',"
sql=sql & "'" & Request.Form("problem") & "',"
sql=sql & "'" & Request.Form("solution") & "',"
sql=sql & "'" & Request.Form("comment") & "',"
sql=sql & "'" & Request.Form("employee") & "',"
sql=sql & "'" & Request.Form("contactperson") & "')"

on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>

</body>
</html>


So, my problem is that I get this error: "No update permissions!"

I've saw that this error happen really often, but there is not any solutions of it.
I've tried a lot of thing to solve the problem, like set permissions to database for IUSR_machine and EVERYONE; copy the database in the other place and so on.

Can you please help me with this problem?

Thank you!
5:53 pm on Mar 28, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:852
votes: 0


Welcomed to WebmasterWorld.

A couple of guess's on whats causing the problems.
(1) Maybe the file is readonly, thus not updateable.
(2) Maybe the values being inserted are larger then the set field sizes.
(3) Maybe a single quote value is sliping in causing errors.
5:59 pm on Mar 28, 2010 (gmt 0)

New User

5+ Year Member

joined:Mar 28, 2010
posts:3
votes: 0


Hi Ocean10000,

First, thank you for your answer!
Second, here is answer of this topics that you guess
(1) The file is not read only.
(2) The values is the right as they should be. I've also tried with null values.
(3) I've copied this code from w3schools, so I think it should be right.
10:06 pm on Mar 28, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:852
votes: 0


try this to get a more discriptive error so we can proceed.

If Err.Number <> 0 Then
Response.Write(Err.Description)
Else
Response.Write("<h3>" & recaffected & " record added</h3>")
End If
4:18 am on Mar 30, 2010 (gmt 0)

Full Member

10+ Year Member

joined:May 14, 2001
posts:262
votes: 0


Is your date field really a "text" field? If not, then you shouldn't wrap it in ticks but rather in hashes.
7:27 pm on Mar 31, 2010 (gmt 0)

New User

5+ Year Member

joined:Mar 28, 2010
posts:3
votes: 0


Hello guys,
First I want to thank you for the asnwers.
Finaly, I solve the problem. First I comment this part:
If Err.Number <> 0 Then
Response.Write(Err.Description)
Else
Response.Write("<h3>" & recaffected & " record added</h3>")
End If
and saw that the problem is was exactly with the date field.
Thank you!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members