高分求救!数据库连接问题!

kaihua11 2003-10-20 09:04:48
前台页面代码如下:
<!-- #include file="../conn_data.inc"-->
<script language="JavaScript">
<!--
function check(){

with(document.addclass[0]){

if (addclass.classname.value==""){
alert("请输入栏目名称");
addclass.classname.focus();
return false;}
if (addclass.c_user.value==""){
alert("请输入管理员");
addclass.c_user.focus();
return false;}
return true;
}
}



//-->
</script>
<!-- #include file="../admin_top.asp"-->
<script language=javascript>
var timer
var winOpen
function IfWindowClosed() {
if (winOpen.closed == true) { document.location.href="classman.asp"
window.clearInterval(timer)
}
}

function Open(URL) {
winOpen=window.open(URL,"","height=180,width=500,left=250,top=200,resizable=yes,scrollbars=no,status=no,toolbar=no,menubar=no,location=no")
timer=window.setInterval("IfWindowClosed()",500);}
</script>
<table width="90%" border="0" height="20" align="center" cellspacing="0" >
<tr>
<td align="center"> </td>
</tr>
</table>
<%
'如果没有请求,则显示一级栏目(类别号为0);否则,显示所请求的栏目类别号。
if request("class")="" then
classid=0
c_fatherid=0

else
classid=request("class")
c_fatherid=request("c_fatherid")
end if

sql="select * from class where c_fatherid=" & classid & " order by id"
set rs=dataconn.execute(sql)

%>
<table width="503" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#6699CC" bordercolorlight="#000000" bordercolordark="#ffffff" bgcolor="#CCCCFF">
<tr>
<td colspan="7" align="left" >
<font color="#FF0000">
<% dim c_name
c_name=request.QueryString("c_name")
if c_name<>""then %>
>><%=c_name%>
<%end if%>
</font>                        
      
<b>栏目管理</b>
</td>
</tr>
<tr >
<td width="50" height="25" align="center">编号</td>
<td width="120" align="center">栏目名称<br>
(点击进入)</td>
<td align="center">显示</td>
<td align="center">内容管理</td>
<td align="center">管理员</td>
<td align="center">修改</td>
<td align="center">删除</td>
</tr>
<%
do while not rs.eof
%>
<tr >
<td align="center"><%=rs("id")%></td>
<td align="center"><a href="./classman.asp?class=<%=rs("id")%>&c_name=<%=rs("c_name")%>"><%=rs("c_name")%></a></td>
<td align="center"><input name="checkbox" type="checkbox"<% if rs("hidden")=0 then response.write"checked" end if %>></td>
<td align="center"> <a href="../content/man.asp?classid=<%=rs("id")%>&c_fatherid=<%=rs("c_fatherid")%>" >进入</a>
</td>
<td align="center"><%=rs("c_user")%></td>
<td align="center" > <a href="javascript:Open('editclass.asp?classid=<%=rs("id")%>')">修改</a></td>
<td align="center">
<%
sql1 = "select * from class where c_fatherid="& rs("id")
set rst=dataconn.execute(sql1)
if not rst.eof then
response.write "<font color=red>非空</font>"
else
%>
<a href="deleteclass.asp?fid=<%=classid%>&class=<%=rs("id")%>">删除</a>
<%
end if
set rst1=nothing
%>
</td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</table>
<hr width="100%" noshade size=1>
<form action="addclass.asp" method="post" name="addclass" onsubmit="return check()" >

<table width="650" align="center" height="46">
<tr>
<td colspan="4" align="center"><b>添加栏目名称</b></td>
</tr>
<input type="hidden" name="classid" value=<%=cint(classid)%> >
<input type="hidden" name="c_fatherid" value=<%=cint(c_fatherid)%> >

<tr>
<td colspan="4" height="2"> </td>
</tr>
<tr>
<td align="center" >栏目名称:<input type="text" name="classname"> </td>
<td align="center" >管 理 员:<input name="c_user" size="10"></td>
<td align="center"> <input type="submit" name="Submit" value="增加栏目">
   <input type="reset" name="reset" value="取消"> </td>
<td align="center"> <input type="button" name="Submit3" value="后退" onclick="history.go(-1)">
  <input type="button" name="Submit2" value="关闭页面" onclick="window.close()">
</td>
</tr>
</table>
</form>
</body>
</html>
...全文
40 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenyu112 2003-10-20
  • 打赏
  • 举报
回复
输出sql2是否正确
angelheavens 2003-10-20
  • 打赏
  • 举报
回复
把set rs1=server.CreateObject("adodb.recordset")
sql1 = "select * from [user] where username='"&username&"'"
rs1.Open sql1,dataconn,3,3

改成:
sql1 = "select * from [user] where username='"&username&"'"
set rs1=dataconn.execute(sql1)

试试
kaihua11 2003-10-20
  • 打赏
  • 举报
回复
不好意思,我试出来了!!!!
需要[user]就可以了,谢谢大家
我先改一下程序,随后给各位加分
kaihua11 2003-10-20
  • 打赏
  • 举报
回复
这一句还是过不去?
dataconn.execute(sql2)
kaihua11 2003-10-20
  • 打赏
  • 举报
回复
sql2 response.write结果如下:
insert into user(username,pass,op) values('个','个',2)
注释:各种id(classid,c_fatherid),op都是int型
qdubit 2003-10-20
  • 打赏
  • 举报
回复
sql2="insert into user(username,pass,op) values('"&username&"','"&pass&"',"&op&")"
应该改成
sql2="insert into user(username,pass,op) values('"&username&"','"&pass&"','"&op&"')"
试试吧。
zorou_fatal 2003-10-20
  • 打赏
  • 举报
回复
sql2="insert into user(username,pass,op) values('"&username&"','"&pass&"',"&op&")"
试试
sql2="insert into [user](username,pass,op) values('"&username&"','"&pass&"',"&op&")"
如果还不行,
先把sql2 response.write出来看看是啥样的.
kaihua11 2003-10-20
  • 打赏
  • 举报
回复
谢谢了!
前几日给予回复的各位高手,等问题解决了我一定给您们分,目前我的改程序!
kaihua11 2003-10-20
  • 打赏
  • 举报
回复
后台页面如下:
报错在这一行:
dataconn.execute(sql2)
原代码如下:

<!-- #include file="../conn_data.inc"-->

<%
dim op
dim username
dim c_user
dim pass
'on error resume next
classid=request("classid")
classname=request("classname")
c_fatherid=request("c_fatherid")
c_user=request("c_user")
username=request("c_user")
pass=request("c_user")
'response.Write(c_father)
'response.end
if cint(c_fatherid) = 0 then
op = 2
else
op = 3
end if

'if classname<>"" then
sql="insert into class (c_name,c_fatherid,c_user) values('" & classname & "'," & classid &",'"& c_user &"')"
dataconn.execute(sql)
'向user表中添加管理员信息
' if c_user<>"" then
set rs1=server.CreateObject("adodb.recordset")
sql1 = "select * from [user] where username='"&username&"'"
rs1.Open sql1,dataconn,3,3
if rs1.eof then
sql2="insert into user(username,pass,op) values('"&username&"','"&pass&"',"&op&")"
'set rs2=server.CreateObject("adodb.recordset")
'rs2.open sql2,dataconn,3,3
dataconn.execute(sql2)
else
if rs1("op")<>op then
dataconn.execute "insert into user (username,pass,op) values('"&username&"','"&pass&"',"&op&")"
end if
end if
rs1.close
set rs1=nothing
'end if
response.redirect "classman.asp?class=" & classid
%>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧