| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 718 人关注过本帖
标题:[求助]如何解决这个asp问题
只看楼主 加入收藏
xiaweier
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-6-7
收藏
 问题点数:0 回复次数:14 
[求助]如何解决这个asp问题

(我想在以下的代码中插入验证输入的候选人(!名字不能为空,不能重名!因为建立的数据库里以有信息,)




<!--#include file="MyFunctions.asp"-->
<%
if request("action")="add" then
conn.execute ("insert into DVote (Name,Info) values ('"&request("Name")&"','"&request("Info")&"')") '---将"推荐候选人"加入到库里
Response.Redirect "index.asp" ' -----自动转到<<投票首页>>
else
%>
<html>
<head>
<title>推荐候选人</title>
</head>
<body background="Bg1.jpg">
<p align="center"><img src="fig.jpg" width="690" height="230"></p>
<form action="recommend.asp?action=add" method="post">
<table width="70%" align="center" border="2">
<tr bgcolor="#00CCFF">
<td align="right">候选人姓名:</TD>
<td><input type="text" name="Name" size="10"></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" align="right">候选人简介:</td>
<td bgcolor="#CCCCCC">
<textarea name="Info" cols="40" rows="3"></textarea></td>
</tr>
</table><br>
<Div align="center">
<input type="submit" value="确定">
<input type="hidden" name="Decsion" value="True">
<input type="reset" value="重新输入">
</Div>
</form>
<p align="center"><a href="vbscript:history.back">返回首页</a></p>
</body>
</html>
<% End If %>

搜索更多相关主题的帖子: asp 
2006-06-15 10:43
xiaweier
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-6-7
收藏
得分:0 
2006-06-15 10:45
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
if request("action")="add" then
nnn=request("Name")
if len(nnn)<2 then
response.write("<script>alert('候选人姓名段');history.back();</script>"):Response.end
end if
sql="select count([Name]) from DVote where [Name]='"&request("Name")&"'"
rs.open sql,conn,1,1
if rs(0)>0 then
response.write("<script>alert('候选人已经存在~!请更换。');history.back();</script>"):Response.end
end if
conn.execute ("insert into DVote (Name,Info) values ('"&nnn&"','"&request("Info")&"')") '---将"推荐候选人"加入到库里
2006-06-15 10:51
xiaweier
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-6-7
收藏
得分:0 
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%'数据库连接,这样的写法不须加ODBC数据源
dim conn
dim connstr
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("MyData.mdb")
conn.Open connstr
%>
<link href="Style.css" rel="stylesheet" type="text/css">
2006-06-15 10:58
xiaweier
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-6-7
收藏
得分:0 

显示的页面空的!
2006-06-15 11:06
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
楼上的,什么意思?说的明白一点

http://www./
2006-06-15 11:08
xiaweier
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-6-7
收藏
得分:0 
是否这里??

<form action="recommend.asp?action=add" method="post">
2006-06-15 11:19
xiaweier
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-6-7
收藏
得分:0 

<!--#include file="MyFunctions.asp"-->
<%
if request("action")="add" then
nnn=request("Name")
if len(nnn)<2 then
response.write("<script>alert('候选人姓名段');history.back();</script>"):Response.end
end if
sql="select count([Name]) from DVote where [Name]='"&request("Name")&"'"
rs.open sql,conn,1,1
if rs(0)>0 then
response.write("<script>alert('候选人已经存在~!请更换。');history.back();</script>"):Response.end
end if
conn.execute ("insert into DVote (Name,Info) values ('"&nnn&"','"&request("Info")&"')") '---将"推荐候选人"加入到库里

%>
<html>
<head>
<title>推荐候选人</title>
</head>
<body background="Bg1.jpg">
<p align="center"><img src="fig.jpg" width="690" height="230"></p>
<form action="recommend.asp?action=add" method="post">
<table width="70%" align="center" border="2">
<tr bgcolor="#00CCFF">
<td align="right">候选人姓名:</TD>
<td><input type="text" name="Name" size="10"></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" align="right">候选人简介:</td>
<td bgcolor="#CCCCCC">
<textarea name="Info" cols="40" rows="3"></textarea></td>
</tr>
</table><br>
<Div align="center">
<input type="submit" value="确定">
<input type="hidden" name="Decsion" value="True">
<input type="reset" value="重新输入">
</Div>
</form>
<p align="center"><a href="vbscript:history.back">返回首页</a></p>
</body>
</html>
<% End If %>

页面不能显示!!!但没报错!!

2006-06-15 11:23
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 

鼠标右键察看源代码 贴出来

2006-06-15 11:35
craft001wen
Rank: 2
等 级:论坛游民
帖 子:242
专家分:62
注 册:2006-5-4
收藏
得分:0 
以下是引用xiaweier在2006-6-15 11:23:19的发言:

<!--#include file="MyFunctions.asp"-->
<%
if request("action")="add" then
nnn=request("Name")
if len(nnn)<2 then
response.write("<script>alert('候选人姓名段');history.back();</script>"):Response.end
end if
sql="select count([Name]) from DVote where [Name]='"&request("Name")&"'"
rs.open sql,conn,1,1
if rs(0)>0 then
response.write("<script>alert('候选人已经存在~!请更换。');history.back();</script>"):Response.end
end if
conn.execute ("insert into DVote (Name,Info) values ('"&nnn&"','"&request("Info")&"')") '---将"推荐候选人"加入到库里

Response.Redirect "index.asp" 在这加上你要的候选人页面就行了!

%>
<html>
<head>
<title>推荐候选人</title>
</head>
<body background="Bg1.jpg">
<p align="center"><img src="fig.jpg" width="690" height="230"></p>
<form action="recommend.asp?action=add" method="post">
<table width="70%" align="center" border="2">
<tr bgcolor="#00CCFF">
<td align="right">候选人姓名:</TD>
<td><input type="text" name="Name" size="10"></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" align="right">候选人简介:</td>
<td bgcolor="#CCCCCC">
<textarea name="Info" cols="40" rows="3"></textarea></td>
</tr>
</table><br>
<Div align="center">
<input type="submit" value="确定">
<input type="hidden" name="Decsion" value="True">
<input type="reset" value="重新输入">
</Div>
</form>
<p align="center"><a href="vbscript:history.back">返回首页</a></p>
</body>
</html>
<% End If %>

页面不能显示!!!但没报错!!

[此贴子已经被作者于2006-6-15 13:46:53编辑过]


2006-06-15 13:46
快速回复:[求助]如何解决这个asp问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028561 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved