第一部分:建立数据库
create database lyb
go
use lyb
go
create table liuyan(
liuyanid int identity not null,
username varchar(50),
datetime datetime,
content varchar(500)
)
create table reply(
replyid int identity not null,
replytime datetime,
replycontent varchar(50)
)
第二部分:写好留言页面
<table>
<tr><td>有事没事都可留言</td></tr>
<tr><td>姓名:</td><td><input type=text name="user" value=""></td></tr>
<tr><td>要说的话:</td><td><textarea name="content" cols="60" rows="8"></textarea></td></tr>
<tr><td></td><td><input type=submit value="确定"><input type=reset value="取消"></td></tr>
</table>
第三部分:写出对数据库操作的过程
sub addmsg()
if(username="" or content="") then
response.write "<script>alert('请留名和话!');location='index.asp'</script>"
else
exec="insert into liuyan([username],[datetime],[content]) values('"&username&"','"&datetime1&"','"&content&"')"
conn.execute exec
response.write "<script>alert('留言成功!');location='index.asp'</script>"
end if
end sub
sub delmsg()
exec="delete from [liuyan] where liuyanid="&clng(request("id"))&""
conn.execute exec
response.write "<script>alert('删除成功!');location='index.asp'</script>"
end sub