工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
楼主: 2002070344

请教一下asp

[复制链接]
 楼主| 发表于 2007-4-2 18:40 | 显示全部楼层
现在就是出现加载不到数据
如图所示.....

[ 本帖最后由 2002070344 于 2007-4-2 18:46 编辑 ]
未命名.jpg
回复

使用道具 举报

发表于 2007-4-2 22:13 | 显示全部楼层
if not isEmpty(request("no")) then
     no=request("no")  
else
     no=1
end if

上面的有问题。。
比如我这样。。
testsql.asp

<%
If Not IsEmpty(request("no")) Then
response.write "keyi"
Else
response.write "haha"
End If
%>

网址是这样,注意:no=后面没有东西
http://localhost/testsql.asp?no=

输入这个网址后,显示的是keyi

所以应该改成这样
<%
If request("no")<>"" Then
response.write "keyi"   
Else
response.write "haha"
End If
%>
回复

使用道具 举报

发表于 2007-4-2 22:14 | 显示全部楼层
所以你那网页应该修改为:
if request("no")<>"" then
     no=request("no")  
else
     no=1
end if
回复

使用道具 举报

 楼主| 发表于 2007-4-2 23:15 | 显示全部楼层

谢谢

我用
if request("no")<>"" then
     no=request("no")  
else
     no=1
end if






if  isEmpty(request("no")) then
     no=request("no")  
else
     no=1
end if


都还是没获取到记录
头晕啊
回复

使用道具 举报

 楼主| 发表于 2007-4-2 23:19 | 显示全部楼层
会不会我的字段选取有问题
我用来查询的字段是no
还有一个是date(这个肯定要改)
回复

使用道具 举报

 楼主| 发表于 2007-4-3 00:36 | 显示全部楼层
好像证实了我的预言,将查询用的关键字段no即编号
改成n之后就恢复正常了
可以加载准备被修改的数据
有达人可以解释下吗
以后选字段还是不要乱来好了
回复

使用道具 举报

发表于 2007-4-3 17:30 | 显示全部楼层
难道no是access的关键字。。。。。。
回复

使用道具 举报

 楼主| 发表于 2007-4-3 20:34 | 显示全部楼层
不知道呢
现在好像发现原来"编号"那个字段
就是原来的no(改成n)
现在又来问题了
录入资料页面,也就是insert页面录入资料不成功
不知道是不是因为它在数据库的属性为"自动编号"的缘故
回复

使用道具 举报

发表于 2007-4-3 20:40 | 显示全部楼层
用过一次ACCESS,好像password也是关键字...
回复

使用道具 举报

发表于 2007-4-3 20:42 | 显示全部楼层
原帖由 2002070344 于 2007-4-3 20:34 发表
不知道呢
现在好像发现原来"编号"那个字段
就是原来的no(改成n)
现在又来问题了
录入资料页面,也就是insert页面录入资料不成功
不知道是不是因为它在数据库的属性为"自动编号"的缘故


不成功?
如何不成功?
SQL语句又是什么?
回复

使用道具 举报

 楼主| 发表于 2007-4-3 22:07 | 显示全部楼层
我先是做个填form的网页insert.asp

<META c>
<[email=%@LANGUAGE=]%@LANGUAGE="VBSCRIPT[/email]" CODEPAGE="936"%>
<!--#include file="dbconn.asp" -->
<link rel="stylesheet" type="text/css" href="style.css">
<body bgcolor="#FFFFFF" marginheight=0 marginwidth=0 leftmargin=0>
<html>
<head>
<title>录入新文档资料</title>
<body>
<%
dim sql
dim rs
%>
<form action="SAVEINSERT.ASP" method="post"  name="form1" target="_self">
  <table width="63%" border="3" align="center" bordercolor="#D4D0C8" id="AutoNumber1" style="border-collapse: collapse">
    <tr>
      <td><div align="center"><strong>录入新文档资料</strong></div></td>
    </tr>
    <tr>
      <td width="100%"><font color="#000080">日期:
        <input name="txtdate" type="text" id="txtdate" size="20" maxlength="10">
        <span class=ap9x><font color="#000080">(格式:2002-1-1) </font></span> </font></td>
    </tr>
    <tr>
      <td><font color="#000080">标题:</font><span class=ap9x>
        <input name="txttopic" type="text" id="txttopic" size="40">
  </span></td>
    </tr>
    <tr>
      <td><span class=ap9x><font color="#000080"><span lang="zh-cn">经办人</span>:</font><font color="#FF0000">
        <input name="txtpeople" type="text" id="txtpeople">
      </font></span></td>
    </tr>
    <tr>
      <td><span class=ap9x><font color="#000080">备注:</font></span><SPAN class=ap9x></SPAN></td>
    </tr>
    <tr>
      <td><font color="#000080"><span class=ap9x><font color="#000080">
        <textarea name="txtnote" cols="60" rows="6" id="txtnote"></textarea>
        <font color="#000080"><font color="#000080"><font color="#000080">
        <input type="submit" name="Submit" value="提交数据">
        </font></font> </font></font></span></font></td>
    </tr>
  </table>
</form>
<p> </p>
</body>
</html>



然后将上面填写的数据传到saveinsert.asp
<META c>
<%@ CODEPAGE="936"%>
<!--#include file="dbconn.asp" -->
<%
dim rs
dim sql
'定义接收数据的临时变量
dim n
dim date1
dim topic
dim people
dim note
'接收数据
n=request.Form("txtn")
date1=request.Form("txtdate")
topic=request.Form("txttopic")
people=request.Form("txtpeople")
note=request.Form("txtnote")
'查询是否有相同编号的信息,若没有则录入
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from file where n="&n
rs.open sql,conn,3,2
if rs.eof then
  '录入新的信息
  rs.addnew
  rs("n")=n
  rs("date")=date1
  rs("topic")=topic
  rs("people")=people
  rs("note")=note
  rs.update
  response.write "录入成功"
else
  response.write "已有相同编号的文件存在!"
end if
rs.close
set rs=nothing  
response.redirect "DEFAULT.ASP"
%>



但就是insert不到新数据

[ 本帖最后由 2002070344 于 2007-4-3 23:30 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-4-3 22:40 | 显示全部楼层
现在又可以了,因为我把"自动编号"的字段改成"数字"属性
然后全部手工输入
现在问题就是只要编号这个字段n不输入数据
整个网页就数据save不了
我这个网页为什么会导致这个缺陷的呢
求教
回复

使用道具 举报

发表于 2007-4-3 23:15 | 显示全部楼层
你的最后一段代码,好像没有对N赋值

以下是我的猜测
你声明了n,但却没有对它进行赋值,所以n的默认值应该是nothing, (很少用vbscript,所以不确定,你自己可以去试验一下)
如果是nothing的话,传到数据库里就是null,而数字字段是不允许为null的,于是,你插入失败.

另外,建议:
出现错误的话最好把错误信息给贴出来.以便判断
回复

使用道具 举报

 楼主| 发表于 2007-4-3 23:40 | 显示全部楼层
谢谢,好像是这么回事,不过暂时试验不了
原本把n的字段属性的数字改成文本试验一下
不过发觉n不输东西进去也是不逻辑的,而且搞乱程序
同时,n不为数字的时候,排序也乱了(原本默认状态下,我是以n倒序排列的,结果都没规则了)
回复

使用道具 举报

 楼主| 发表于 2007-4-3 23:41 | 显示全部楼层
我还以为不给数字字段赋值,该字段就是0呢,没常识
回复

使用道具 举报

发表于 2007-4-4 13:55 | 显示全部楼层
—_—还在做?

上面好像已经说了
补充:如果数据库字段n是自动编码的话,人工赋值n是插不进去的


还有以前我也吃过sql关键字的亏,调试了很久
后来改用sqlserver基本就不会出现这问题啦...
sqlserver设计数据库时就会自动把关键字加上中括号


下面是SQL关键字清单:

action add aggregate all
alter after and as
asc avg avg_row_length auto_increment
between bigint bit binary
blob bool both by
cascade case char character
change check checksum column
columns comment constraint create
cross current_date current_time current_timestamp
data database databases date
datetime day day_hour day_minute
day_second dayofmonth dayofweek dayofyear
dec decimal default delayed
delay_key_write delete desc describe
distinct distinctrow double drop
end else escape escaped
enclosed enum explain exists
fields file first float
float4 float8 flush foreign
from for full function
global grant grants group
having heap high_priority hour
hour_minute hour_second hosts identified
ignore in index infile
inner insert insert_id int
integer interval int1 int2
int3 int4 int8 into
if is isam join
key keys kill last_insert_id
leading left length like
lines limit load local
lock logs long longblob
longtext low_priority max max_rows
match mediumblob mediumtext mediumint
middleint min_rows minute minute_second
modify month monthname myisam
natural numeric no not
null on optimize option
optionally or order outer
outfile pack_keys partial password
precision primary procedure process
processlist privileges read real
references reload regexp rename
replace restrict returns revoke
rlike row rows second
select set show shutdown
smallint soname sql_big_tables sql_big_selects
sql_low_priority_updates sql_log_off sql_log_update sql_select_limit
sql_small_result sql_big_result sql_warnings straight_join
starting status string table
tables temporary terminated text
then time timestamp tinyblob
tinytext tinyint trailing to
type use using unique
unlock unsigned update usage
values varchar variables varying
varbinary with write when
where year year_month zerofill
回复

使用道具 举报

发表于 2007-4-4 19:22 | 显示全部楼层
关键字用反单引号引起来...
回复

使用道具 举报

发表于 2007-4-5 00:18 | 显示全部楼层
对于关键字
好像mysql用单引号
而mssql是用中括号

还是不确定...
只是恍恍惚惚记得是这样的。
回复

使用道具 举报

发表于 2007-4-5 00:43 | 显示全部楼层
而37#所说的反单引号是通用的
回复

使用道具 举报

发表于 2007-4-5 02:37 | 显示全部楼层
原帖由 admin 于 2007-4-4 13:55 发表
—_—还在做?

上面好像已经说了
补充:如果数据库字段n是自动编码的话,人工赋值n是插不进去的


还有以前我也吃过sql关键字的亏,调试了很久
后来改用sqlserver基本就不会出现这问题啦...
sqlserver设 ...


我也考虑到是关键词的问题。。。。。
只可惜没有查到所有的关键词。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2025-5-15 03:48

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表