asp的问题

[复制链接]
查看11 | 回复4 | 2011-2-17 01:34:02 | 显示全部楼层 |阅读模式
程序应该没错啊,我只有20分,请帮下!
conn.asp
%
dim db,conn,connstr
db=\\\"data.mdb\\\"
set Conn = server.CreateObject(\\\"ADODB.Connection\\\")
connstr=\\\"driver={Microsoft Access Driver (*.mdb)};dbq=\\\"

reg.asp
!--#include file=\\\"conn.asp\\\"--
%
dname=request.form(\\\"dname\\\")
dpass=request.form(\\\"dpass\\\")
if dname\\\"\\\" then
sql=\\\"select * from QJ_User\\\"
set rs=server.createobject(\\\"adodb.recordset\\\")
rs.open sql,conn,1,3
rs.addnew
rs(\\\"QJ_LoginName\\\")=dname

rs(\\\"QJ_LoginPass\\\")=dpass
rs.update
session(\\\"QJ_LoginName\\\")=dname
response.redirect \\\"ok.asp\\\"
end if
%

html
head
style type=\\\"text/css\\\"
!--
td
{ font-size: 12px; line-height: 17px }
body
{ font-size: 12px; line-height: 17px }
p
{ margin-top: 1; margin-bottom: 1 }
a:link
{ text-decoration: none; color: black }
a:visited
{ text-decoration: none; color: black }
a:active
{ text-decoration: none }
a:hover
{ text-decoration: underline; color: red }
--
/style
meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=gb2312\\\"
meta name=\\\"GENERATOR\\\" content=\\\"Microsoft FrontPage 6.0\\\"
meta name=\\\"ProgId\\\" content=\\\"FrontPage.Editor.Document\\\"
title注册/title
SCRIPT LANGUAGE=\\\"JavaScript\\\"
!--//
function checkadd()
{

if (document.postart.dname.value.length1)
{

alert(\\\"请填写姓名\\\");

document.postart.dname.focus();

return false;

}

if (document.postart.dpass.value.length1)
{

alert(\\\"请填写密码!\\\");

document.postart.dpass.focus();

return false;

}

}
//--
/SCRIPT
/head
body
br
div align=\\\"center\\\"
center
table border=\\\"0\\\" width=\\\"100%\\\" cellspacing=\\\"0\\\" cellpadding=\\\"0\\\" height=\\\"292\\\"

form action=\\\"\\\" method=\\\"post\\\" name=\\\"postart\\\" onsubmit=\\\"return checkadd()\\\"

tr

td width=\\\"100%\\\" colspan=\\\"2\\\" height=\\\"30\\\"

/td

/tr

tr

td width=\\\"36%\\\" align=\\\"right\\\" height=\\\"26\\\"姓名:/td

td width=\\\"64%\\\" height=\\\"26\\\"input type=\\\"text\\\" name=\\\"dname\\\" size=\\\"30\\\" maxlength=\\\"50\\\" style=\\\"border: 1 solid #008000\\\"

font color=\\\"#FF0000\\\"*/font/td

/tr

tr

td width=\\\"36%\\\" align=\\\"right\\\" height=\\\"30\\\"密码:/td


td width=\\\"64%\\\" height=\\\"30\\\"input type=\\\"password\\\" name=\\\"dpass\\\" size=\\\"30\\\" maxlength=\\\"50\\\" style=\\\"border: 1 solid #008000\\\"

font color=\\\"#FF0000\\\"*/font/td

/tr

tr

td width=\\\"100%\\\" align=\\\"right\\\" colspan=\\\"2\\\" height=\\\"30\\\"

p align=\\\"center\\\"input type=\\\"submit\\\" value=\\\"提交\\\" name=\\\"submit\\\"

input type=\\\"reset\\\" value=\\\"取消\\\" name=\\\"reset\\\" input type=\\\"button\\\" value=\\\"返回\\\" name=\\\"back\\\" onclick=\\\"javascript:history.back()\\\"/td
回复

使用道具 举报

千问 | 2011-2-17 01:34:02 | 显示全部楼层
<p>

<pre class=\\\"answer-content\\\">if dname\\\"\\\" then
sql=\\\"insert into qj_user(qj_loginname,qj_loginpass) values(\\\'\\\"defds123dnamedefds123\\\"\\\',\\\'\\\"defds123dpassdefds123\\\"\\\')\\\"
conn.execute(sql)
session(\\\"QJ_LoginName\\\")=dname
response.redirect \\\"ok.asp\\\"
end if

直接用插入语句试下

</p>
回复

使用道具 举报

千问 | 2011-2-17 01:34:02 | 显示全部楼层
<p>

<pre class=\\\"answer-content\\\">db.fun 可能是自己定义得一个文件,或许是一些函数!

#include file 和 #include virtual的区别,介绍这方面的文章也有不少,在此将二者的区别再总结一下,仅供参考:
1。#include file 包含文件的相对路径,#include virtual包含文件的虚拟路径。
2。在同一个虚拟目录内,!--#include file=\\\"file.asp\\\"--和!--#include virtual=\\\"file.asp\\\"--效果是相同的,但假设虚拟目录名为myweb,则!--#include virtual=\\\"myweb/file.asp\\\"--也可以通过调试,但我们知道!--#include file=\\\"myweb/file.asp\\\"--是绝对要报错的。
3。如果一个站点下有2个虚拟目录myweb1和myweb2,myweb1下有文件file1.asp,myweb2下有文件file2.asp,如果file1.asp要调用file2.asp,那么在file1.asp中要这样写:!--#include virtual=\\\"myweb2/file2.asp\\\"--,在这种情况下用#include file是无法实现的,用!--#include file=\\\"myweb2/file2.asp\\\"--必然报错。相反,在myweb2的文件中包含myweb1中的文件也是一样。如果该被包含文件在某个文件夹下面,只要在虚拟路径中加上该文件夹即可。
4。不论用#include file 还是 #include virtual,在路径中用“/”还是“\\\\”或者二者交叉使用都不会影响编译效果,程序会顺利执行。
5。以上情况不适用于2个站点文件的相互调用,而且在同一个站点内,!--#include file=\\\"file.asp\\\"--和!--#include virtual=\\\"file.asp\\\"--等效,但假设站点名为website,使用!--#include virtual=\\\"website/file.asp\\\"--是错误的。

</p>
回复

使用道具 举报

千问 | 2011-2-17 01:34:02 | 显示全部楼层
<p>

<pre class=\\\"answer-content\\\">!--#include file=\\\"conn.asp\\\"--
%
if request.QueryString(\\\"action\\\")=\\\"log\\\" then
dname=request.form(\\\"dname\\\")
dpass=request.form(\\\"dpass\\\")
if dname\\\"\\\" then
sql=\\\"select * from QJ_User\\\"
set rs=server.createobject(\\\"adodb.recordset\\\")
rs.open sql,conn,1,3
rs.addnew
rs(\\\"QJ_LoginName\\\")=dname

rs(\\\"QJ_LoginPass\\\")=dpass
rs.update
session(\\\"QJ_LoginName\\\")=dname
response.redirect \\\"ok.asp\\\"
end if
end if
%

html
head
style type=\\\"text/css\\\"
!--
td
{ font-size: 12px; line-height: 17px }
body
{ font-size: 12px; line-height: 17px }
p
{ margin-top: 1; margin-bottom: 1 }
a:link
{ text-decoration: none; color: black }
a:visited
{ text-decoration: none; color: black }
a:active
{ text-decoration: none }
a:hover
{ text-decoration: underline; color: red }
--
/style
meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=gb2312\\\"
meta name=\\\"GENERATOR\\\" content=\\\"Microsoft FrontPage 6.0\\\"
meta name=\\\"ProgId\\\" content=\\\"FrontPage.Editor.Document\\\"
title注册/title
SCRIPT LANGUAGE=\\\"JavaScript\\\"
!--//
function checkadd()
{

if (document.postart.dname.value.length1)
{

alert(\\\"请填写姓名\\\");

document.postart.dname.focus();

return false;

}

if (document.postart.dpass.value.length1)
{

alert(\\\"请填写密码!\\\");

document.postart.dpass.focus();

return false;

}

}
//--
/SCRIPT
/head
body
br
div align=\\\"center\\\"
center
table border=\\\"0\\\" width=\\\"100%\\\" cellspacing=\\\"0\\\" cellpadding=\\\"0\\\" height=\\\"292\\\"

form method=\\\"post\\\" name=\\\"postart\\\" action=\\\"reg.asp?action=log\\\" onsubmit=\\\"return checkadd()\\\"

tr

td width=\\\"100%\\\" colspan=\\\"2\\\" height=\\\"30\\\"

/td

/tr

tr

td width=\\\"36%\\\" align=\\\"right\\\" height=\\\"26\\\"姓名:/td

td width=\\\"64%\\\" height=\\\"26\\\"input type=\\\"text\\\" name=\\\"dname\\\" size=\\\"30\\\" maxlength=\\\"50\\\" style=\\\"border: 1 solid #008000\\\"

font color=\\\"#FF0000\\\"*/font/td

/tr

tr

td width=\\\"36%\\\" align=\\\"right\\\" height=\\\"30\\\"密码:/td


td width=\\\"64%\\\" height=\\\"30\\\"input type=\\\"password\\\" name=\\\"dpass\\\" size=\\\"30\\\" maxlength=\\\"50\\\" style=\\\"border: 1 solid #008000\\\"

font color=\\\"#FF0000\\\"*/font/td

/tr

tr

td width=\\\"100%\\\" align=\\\"right\\\" colspan=\\\"2\\\" height=\\\"30\\\"

p align=\\\"center\\\"input type=\\\"submit\\\" value=\\\"提交\\\" name=\\\"submit\\\"


input type=\\\"reset\\\" value=\\\"取消\\\" name=\\\"reset\\\"input type=\\\"button\\\" value=\\\"返回\\\" name=\\\"back\\\" onclick=\\\"javascript:history.back()\\\"/td
/tr
/form
/table

</p>
回复

使用道具 举报

千问 | 2011-2-17 01:34:02 | 显示全部楼层
<p>

<pre class=\\\"answer-content\\\">我在本地测试提示是 CONN第6行 未指定错误
把{Microsoft Access Driver (*.mdb)} {} 去了 就好了
代码如下:
%
dim db,conn,connstr
db=\\\"data.mdb\\\"
set conn = server.createobject(\\\"adodb.connection\\\")
connstr = \\\"DRIVER=Microsoft Access Driver (*.mdb);DBQ=\\\"

</p>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行