ASP网络编程数据库连接的from子语句语法错误

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
dim connstr
connstr="provider=microsoft.jet.oledb.4.0;data source=" & server.MapPath("date\user.mdb")
set cn=server.CreateObject("ADODB.Connection")
cn.open connstr
%>
<%
exec="select * from user"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,cn,1,1
%>
<html>
代码写到这里我运行的时候它就提示from子语句语法错误,请问我什么地方出了错?详细一点。
顶楼:为什么user要用[]引起来了,不用""引吗?我用的是access。二楼:我的数据库名字叫做user,表也叫做user,这个会不会跟我的这两个名字一样有关呢?

exec="select * from [user]"

------------------------------------
user是数据库保留字段,需要用[]起来,这是规定
下面的sql是指数据库语句,如select * from [user],而不是数据库的意思,所以和access没太大关系
------------------------------------

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 注:User=use unlock unsigned update usage values varchar variables varying varbinary with write when where year year_month zerofill
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-02-28
exec="select * from 表的名称而不是数据库文件名"
------------------------------------------------------
假设该 数据库文件名为user.mdb,表名为username
可以这样写

set rs = server.createobject("adodb.recordset")
sql="select * from username
rs.open sql,conn,1,1
--------------------------------------------------
这是我从我的网页登录页面直接复制下来修改的,运行过没有错的
那你尝试一下阿
还有你尝试改一下那句:
connstr = "DBQ=" + server.mappath("user.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
第2个回答  2007-03-01
楼上正解
相似回答