主题:老是提示:操作必须使用一个可更新的查询
我用asp做一个从Excel2003将数据导入Access2003的程序,但老是提示:操作必须使用一个可更新的查询,我已经给数据库添加来宾用户的所有权限了,也还是一样,我的程序如下,望得到高手指点:
dim conn
dim conn2
'连接目的数据表
set conn=CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=" & Server.MapPath("student.mdb")
'连接待读入excel数据表
set conn2=CreateObject("ADODB.Connection")
conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Extended properties='Excel 5.0;hdr=yes;imex=1';Data Source="& Server.MapPath("upload/"&FileName)
'查询待读入excel数据表
sql = "SELECT * FROM [Sheet1$]"
set rs = conn2.execute(sql)
'将数据循环读入目的数据库
while not rs.eof
'查询相同的数据,以学号为唯一标识
dim icount
checksamesql="select stu_no from student where stu_no = '"& fixsql(rs(0)) &"'"
set checksamers = conn.execute(checksamesql)
icount = checksamers.recordcount
checksamers.close
set checksamers= nothing
if icount<=0 then
sql = "insert into student(stu_no,stu_name,stu_sex,stu_course,stu_grade,moon) values('"& fixsql(rs(0)) &"','"& trim(fixsql(rs(1))) &"','"& fixsql(rs(2)) &"','"& fixsql(rs(3)) &"','"& fixsql(rs(4)) &"','"& fixsql(rs(5)) &"')"
conn.execute(sql)'[color=FF0000]提示在这一行出错[/color]
end if
rs.movenext
wend
set oFile=nothing'释放文件对象
next
set upfile=nothing'释放上传对象
'释放数据连接对象
conn.close
set conn = nothing
conn2.close
set conn2 = nothing
'删除上传数据表
Set fso = CreateObject("Scripting.FileSystemObject")
FiLePaTh = Server.MapPath("upload/"&FileName)
If fso.FileExists(FiLePaTh) Then
fso.DeleteFile(FiLePaTh)
end if
Set fso = nothing
response.Write "<script LANGUAGE='javascript'>alert('数据导入成功!');history.go(-1);</script>"
response.End
dim conn
dim conn2
'连接目的数据表
set conn=CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=" & Server.MapPath("student.mdb")
'连接待读入excel数据表
set conn2=CreateObject("ADODB.Connection")
conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Extended properties='Excel 5.0;hdr=yes;imex=1';Data Source="& Server.MapPath("upload/"&FileName)
'查询待读入excel数据表
sql = "SELECT * FROM [Sheet1$]"
set rs = conn2.execute(sql)
'将数据循环读入目的数据库
while not rs.eof
'查询相同的数据,以学号为唯一标识
dim icount
checksamesql="select stu_no from student where stu_no = '"& fixsql(rs(0)) &"'"
set checksamers = conn.execute(checksamesql)
icount = checksamers.recordcount
checksamers.close
set checksamers= nothing
if icount<=0 then
sql = "insert into student(stu_no,stu_name,stu_sex,stu_course,stu_grade,moon) values('"& fixsql(rs(0)) &"','"& trim(fixsql(rs(1))) &"','"& fixsql(rs(2)) &"','"& fixsql(rs(3)) &"','"& fixsql(rs(4)) &"','"& fixsql(rs(5)) &"')"
conn.execute(sql)'[color=FF0000]提示在这一行出错[/color]
end if
rs.movenext
wend
set oFile=nothing'释放文件对象
next
set upfile=nothing'释放上传对象
'释放数据连接对象
conn.close
set conn = nothing
conn2.close
set conn2 = nothing
'删除上传数据表
Set fso = CreateObject("Scripting.FileSystemObject")
FiLePaTh = Server.MapPath("upload/"&FileName)
If fso.FileExists(FiLePaTh) Then
fso.DeleteFile(FiLePaTh)
end if
Set fso = nothing
response.Write "<script LANGUAGE='javascript'>alert('数据导入成功!');history.go(-1);</script>"
response.End