ASP 简单的提示框问题,及数据插入数据库问题

来源:百度知道 编辑:UC知道 时间:2024/07/07 03:44:33
请ASP高手帮忙!!!我的系统是用ASP+ACCESS开发的,我有两个问题:
1、我在数据库任何一张数据表都没有设置主键,所以在往数据库插入数据时有可能会导致有些必须唯一的字段的值不唯一,我想实现:当我插入某个值时,如果该值与数据表的某一特定的字段的值相同,就不允许其添加此数据,并提示“XX必须唯一!”
2、在做数据插入时,多条记录一次性通过循环的方式一条一条地插入到数据库中,我想实现:在插入最后一条数据时提示“插入成功!”请高手指教,帮我修改一下!!我的程序如下:
<% dim sql,rs
a=session("userno")
set rs=server.CreateObject("ADODB.Recordset")
sql="Select * from selectcourse where teacherno='"&a&"'"
rs.open sql,newsconn
%>
<table border="1" width="500">
<form name="choisecourse" method="post" action="" >
<tr bgcolor="#e0e0e0">
<td>ID</td>
<td>学生代号</td>
<td>课程代号</td>
<td>教师代号</td>
<td>成绩</td>
</tr>
<%
Do While Not rs.Eof
Dim aa
aa=rs("id")
%>
<tr >

<!--#include file="conn.asp"-->
<%
news_title=request.Form("news_title")
news_content=request.Form("news_content")
sql="insert into news(news_title,news_content) values('"&news_title&"','"&news_content&"')"
conn.execute sql
response.Write "<script>alert('添加成功!!!');location.href='admin_news.asp'</script>"

%>