数据库连接

来源:百度知道 编辑:UC知道 时间:2024/05/22 00:44:18
各位高手帮小弟看看,我用的是 windows xp
执行下列程序时
<% dim connstr,myconn,mysql

connstr="dsn=use"
set myconn=server.createobject ("adodb.connection")
myconn.connectionstring=connstr
myconn.open
mysql="insert into user(username,pwd,other) values ('ddffdf','hhhh','ff')"
myconn.execute mysql

response.write"记录添加成功"
%>
出现如下错误:

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] 操作必须使用一个可更新的查询。

将{mysql="insert into user(username,pwd,other) values ('ddffdf','hhhh','ff')"
myconn.execute mysql }这两行注释掉就行了,
<% dim connstr,myconn,mysql
connstr="dsn=myuser"
set myconn=server.createobject ("adodb.connection")
myconn.connectionstring=connstr
myconn.open
mysql="insert into myusers (username

insert into user(username,pwd,other) values ('ddffdf','hhhh','ff')
改成
insert into `user`(username,pwd,other) values ('ddffdf','hhhh','ff')"

user是关键字
你在user两边加上一个符号"`" 就是“1”键左边那个键。

mysql="insert into [user] (username,pwd,other) values ('ddffdf','hhhh','ff')"
myconn.execute (mysql)

拿就是你sql语句写的不对了 你把你的语句放sql企业管理器里面去运行一下 能运行伐