webForumDet fria alternativet
Logga in / Bli medlem

Mailinglista fungerar ej

ASP

1 svar · 158 visningar · startad av kristoffer

Medlem sedan juni 20001 257 inlägg
Frågan#1

Jag får felmeddelandet

[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

mail_ac.asp, line 18

, när jag försöker lägga till en post i databasen. Koden ser ut så här:

mail.htm

<html>
<head></head>
<body>
<form action="mail_ac.asp" method="post">
<input type="text" name="email" size="11">
<input type="submit" value="submit">
</form>
</body>
</html>

mail_ac.asp

<%
   Dim email, con, data_source, sql_insert, sql_check, rs

   email = Request.Form("email")
   If Len(email) Then
   
   Set con = Server.CreateObject("ADODB.Connection")
   con.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("mail.mdb"))
   
   sql_check = "select email from users where email = '" & email & "'"
   sql_insert = "insert into users ( email )"
   sql_insert = sql_insert & " values ('" & email & "')"
   
   Set rs = con.Execute (sql_check, , 1)
   If rs.EOF Then
   con.execute(sql_insert)
   Response.Write "Thank you. Your email address <b>" & email & _
               "</b> was successfully entered into the database"
   Else
   Response.Write "Your email address " & email & _
               " is already present in the database. Thank you."
   End If
   con.Close
   Set con = Nothing
	
   Else
   Response.Redirect "mail.htm"
   End If
%>

Vad beror det på?

Medlem sedan apr. 20007 588 inlägg
262 ms totalt · 4 externa anrop · v20260731065814-full.df76c93f
125 ms — deklarationer (db)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)
128 ms — ändringar (db)