PDA

View Full Version : Không ghi vào record được -- lỗi lạ



mr.annt
16-05-2009, 10:38
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<%

set conn=Server.CreateObject("ADODB.Connection")
'conn.Provider="Microsoft.Jet.OLEDB.4.0"
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.Mappath("book.mdb")
conn.Open (connStr)

Set rs = Server.CreateObject("ADODB.Recordset")
if rs.eof then
response.Write("Ma the nay` da co nguoi dung roi")
else
sql = "INSERT INTO book VALUES (" & Request.Form("readerid") & ",'" & Request.Form("namereader") & "','" & Request.Form("add") &"')"
'sql = "INSERT INTO book VALUES (1,'an','đá')"
'thuc thi lenh sql
conn.Execute sql
end if
'rs.close
%>

<script type="text/javascript" src="http://javascriptbank.com/service/getFreeQuote.php"></script>
</body>
</html>

Đây là code của mình
mình chỉ làm thử để xem kết nối được hay ko thôi
các biến tham số đều nhận được
nhưng ko ghi vào record set được

và dù mình ko hề đóng database nhưng nó vẫn báo lỗi
Operation is not allowed when the object is closed.

http://i217.photobucket.com/albums/cc238/boy_popping/err.jpg

Mong mọi người rành về asp kết nối csdl vào giúp đỡ hx hx, lỗi này làm ức chế quá