还是ASP和存储过程的问题,解决马上给分

lyzzbbgo 2004-08-04 02:11:24
set pinsert = Server.CreateObject("ADODB.Command")
pinsert.ActiveConnection = MM_web_STRING
pinsert.CommandText = sql
pinsert.CommandType = 4
pinsert.CommandTimeout = 0
pinsert.Prepared = true
pinsert.Execute() '在这里出错

sql是一句存储过程,并且在查询分析器里运行正常.

错误提示:
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'

[Microsoft][ODBC SQL Server Driver]语法错误或违反访问规则

/RenShiZu/donewemployee.asp,行 41
...全文
193 16 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
hailang3275 2004-08-04
  • 打赏
  • 举报
回复
sql是一句存储过程,并且在查询分析器里运行正常.
但是在asp中就不一定通过了
你还是贴出了看看了
lyzzbbgo 2004-08-04
  • 打赏
  • 举报
回复
明白了...原来pinsert.CommandText里是不能放参数的....FAINT...
lyzzbbgo 2004-08-04
  • 打赏
  • 举报
回复
Cloria817(心晴) 你那个方法是可以的,可是...我这个哪里错了呢?
Cloria817 2004-08-04
  • 打赏
  • 举报
回复
我晕了,我也不知道是哪里错了,帮你顶,关注中...................
lyzzbbgo 2004-08-04
  • 打赏
  • 举报
回复
alter procedure pInsertEmployee
(@ID char(5),@Name nvarchar(4),@Sex char(1),@Birthday smalldatetime,
@EnterDay smalldatetime,@Department nvarchar(10),@LastSchool nvarchar(30),
@Specialty nvarchar(20),@HomeTel varchar(20),@IDCard varchar(18),
@HomeTown nvarchar(30),@StudyLevel nvarchar(10),@Remark nvarchar(50)=null)
as
insert into employeebaseinfo
(id,name,sex,birthday,enterday,department,lastschool,
specialty,hometel,idcard,hometown,StudyLevel,remark)
values
(@id,@name,@sex,@birthday,@enterday,@department,@lastschool,
@specialty,@hometel,@idcard,@hometown,@StudyLevel,@remark)
if @@error<>0 or @@rowcount=0
raiserror('員工記錄插入失敗',14,1)
popcode 2004-08-04
  • 打赏
  • 举报
回复
过程贴出来看看
lyzzbbgo 2004-08-04
  • 打赏
  • 举报
回复
我想会不会是少了左右2个双引号的关系?
lyzzbbgo 2004-08-04
  • 打赏
  • 举报
回复
to: Cloria817(心晴) ( )


参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
lyzzbbgo 2004-08-04
  • 打赏
  • 举报
回复
<!--#include file="../Connections/web.asp" -->
<!--#include virtual="/function.asp"-->


<%
id=request("id")
name=request("name")
sex=request("sex")
birthday=request("birthday")
enterday=request("enterday")
department=request("department")
lastschool=request("lastschool")
hometown=request("hometown")
Specialty=request("Specialty")
HomeTel=request("HomeTel")
IDCard=request("IDCard")
StudyLevel=request("StudyLevel")
Remark=request("Remark")
%>

<%
sql="pInsertEmployee "
sql=sql&SQLStr(id,true,false,true)&SQLStr(name,true,true,true)&SQLStr(sex,true,false,true)
sql=sql&SQLStr(birthday,true,false,true)&SQLStr(enterday,true,false,true)
sql=sql&SQLStr(department,true,true,true)&SQLStr(lastschool,true,true,true)
sql=sql&SQLStr(specialty,true,true,true)&SQLStr(hometel,true,false,true)
sql=sql&SQLStr(idcard,true,false,true)&SQLStr(hometown,true,true,true)
sql=sql&SQLStr(studylevel,true,true,true)&SQLStr(remark,true,true,false)
'Response.Write(sql)
%>

<%
on error resume next

set pinsert = Server.CreateObject("ADODB.Command")
pinsert.ActiveConnection = MM_web_STRING
pinsert.CommandText = sql
pinsert.CommandType = 4
pinsert.CommandTimeout = 0
pinsert.Prepared = true
pinsert.Execute

if err.number<>0 then
witherror(err.description)
end if
%>
<script language="JavaScript" type="text/JavaScript">
alert("人員添加成功!");
//window.history.back();
</script>

function.asp里的2个函数
=======================
function SQLStr(str,isstr,isN,isD)
if isstr=true then str="'"&str&"'"
if isN=true then str="N"&str
if isD=true then str=str&","
SQLStr=str
end function

function witherror (errdescription)
response.Redirect("/error.asp?errdescription="&errdescription)
end function
king2003 2004-08-04
  • 打赏
  • 举报
回复
你最好都贴出来
Cloria817 2004-08-04
  • 打赏
  • 举报
回复
str="exec sql"
set rs=server.createobject("adodb.recordset")
rs.open str,conn,1,1

你TRY这样方法吧
lyzzbbgo 2004-08-04
  • 打赏
  • 举报
回复
sql是前面定义的字符串,也就是存储过程名和参数
skyboy0720 2004-08-04
  • 打赏
  • 举报
回复
pinsert.CommandText = 存储过程名
king2003 2004-08-04
  • 打赏
  • 举报
回复
sql??哪来的
lyzzbbgo 2004-08-04
  • 打赏
  • 举报
回复
楼上的不对...
Cloria817 2004-08-04
  • 打赏
  • 举报
回复
set pinsert = Server.CreateObject("ADODB.Command")
pinsert.ActiveConnection = MM_web_STRING
pinsert.CommandText = "sql"
pinsert.CommandType = 4
pinsert.CommandTimeout = 0
pinsert.Prepared = true
pinsert.Execute()

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧