首页 美女贴图 网络日记 重庆租房 搜索指南 网络电视 飘网音乐 飘网博客 精彩网址 友情链接 飘网地图 本站留言
飘网中国
专题:网络营销 | 网站设计 | QQ技巧 | 搜索优化 | 菜鸟进阶 | 病毒攻防 | 网络技术 | 系统应用 | 本站作品 | 常用软件 | 工具软件 |
飘网中国>>网站设计>>正文

教程:ASP+SQL Server制作留言板的完整小例子

编辑:飘网 来源: 更新:2007-1-11 点击:
【字体:

摘要:教程:ASP+SQL Server制作留言板的完整小例子,写写关于SQL Server数据库的简单使用过程的教程,也算一个小总结!记录一些常用的方法,关键字,单词等,供以后查阅用!我们用ASP+SQL Server做个简单的留言板为例!
关键字:ASP SQL Server 留言板 
正文:
操作(INSERT、 UPDATE、 DELETE),而仅是执行触发器本身
--或者说发生Delete事件时执行,该触发器AS后语名会替换过delete语句的执行

AS
Delete From subFeedback where Feedback_ID in(select Feedback_ID from deleted)
--删除表subFeedback外键与删除feedback主键相同的值
Delete From Feedback where Feedback_ID in(select Feedback_ID from deleted)
 


2、第二个触发器:当subFeedback有新增记录时,Feedback.subFeedback_count字段记数增加! Create Trigger Trigger_update_subFeedback
ON subFeedback
For insert   
--注间和Instead OF的区别,For是当insert语句执行完后再执行解发器AS后的语句

AS
update Feedback set subFeedback_count=subFeedback_count+1 where Feedback_ID in(select Feedback_ID from inserted)
 

    另外:如果考虑的较周全点,当subFeedback中的记录删除时,Feedback_subFeedback_count字段还要减1,触发器的写法和上面一相似,为减短教程,就不在增加!

四、建立两个存储过程用来保存增加的Feedback和subFeedback记录 

Create Procedure proc_insert_Feedback --创建存储过程proc_insert_Feedback
@Title nvarChar(256),@Content text  --定义参数变量
AS 
Insert into Feedback (Title,Content) values(@Title,@Content) --执行语句

GO

Create Procedure proc_insert_subFeedback 
@Feedback_ID int,@Content text
AS 
Insert into subFeedback (Feedback_ID,Content) values(@Feedback_ID,@Content)
 

五、建立asp文件,完成留言板制作!

1、创建conn.asp文件,与数据库连接。 <%
dim conn 
set conn=Server.createobject("ADODB.CONNECTION")      '创建连接对象

conn.open="Provider=SQLOLEDB; Data Source=127.0.0.1;" & _
"Initial Catalog=Feedback; User ID=sa; password=sa;"      
'打开连接。换成你的server-IP(如果也是本机不用修改),数据库用户名,密码!
%>

2、创建List.asp显示留言,内容。这里我把增加的 Form 也加到了文件底部,减少文件的个数。 <!--#include file="conn.asp"--><!--用include file包含数据库连接文件。-->

<%
SQL="select * from Feedback"
Set rs=Server.CreateObject("ADODB.Recordset")      '创建数据集rs
rs.open SQL,conn,1,3   '打开

if not rs.eof then

 output=""   '定义字符串变量output,输出
 do while not rs.eof           '外循环开始
 
 output=output&rs("title")
 output=output&"--<a href=Feedback.asp?feedback_ID="&rs("feedback_ID")&"&title="&rs("title")&">回复该留言</a>["&cstr(rs("subFeedback_count"))&"]<hr>"
'建立回复留言的链接,并把要回复的留言的记录Feedback_ID和Title传给Feedback.asp
'Feedback用来标志是回复了哪条记录,增加数据库用!Title用来显示回
[1][2][3][4]
上一篇:ASP调用带参数存储过程的几种方式
下一篇:QQ本地密码验证破解,快来看密码破解!
最新文章 更多
推荐文章 更多
热门文章 更多
© 2005-2010 飘网中国 版权所有
站长邮箱:①LCC-749AT163.com ②FlymornATgmail.com(AT改为@)
如转载时,请注明出处;本站部分资源来自网络,如有侵权,请来信说明;飘易文章系统 HTML版.
渝ICP备05000119号