大虾求救!!dreamweaver不能完成以表单中输入的数据为变量的存储过程的自动RAD
存储过程为(在SQL Server2000中运行完全正确):
create procedure update_subscribe
@kind varchar(21),
@notsale bit,
@sale bit,
@salein2month bit,
@direction12 varchar(21),
@price12 tinyint,
@lasthouse bit,
@news bit,
@phonenumber varchar(21)
as
begin
if exists
(
select *
from subscribe
where phonenumber=@phonenumber
)
begin
update subscribe
set kind=@kind,
notsale=@notsale,
sale=@sale,
salein2month=@salein2month,
direction12=@direction12,
price12=@price12,
lasthouse=@lasthouse,
news=@news
where phonenumber=@phonenumber
end
else begin
insert subscribe
(
kind,
notsale,
sale,
salein2month,
direction12,
price12,
lasthouse,
news,
phonenumber
)
values
(
@kind,
@notsale,
@sale,
@salein2month,
@direction12,
@price12,
@lasthouse,
@news,
@phonenumber
)
end
end
GO
------------------------------
subscribe表如下:
kind nvarchar(21)
notsale bit(1)
sale bit(1)
salein2month bit(1)
direction12 nvarchar(21)
price12 tinyint(1)
lasthouse bit(1)
news bit(1)
phonenumber nvarchar(21)
----------------------------
上述存储过程update_subscribe的目的是检索表中的phonenumber字段,如果即将存入的记录中的电话号码已经在表中存在则数据库操作为"update"(更新除phonenumber外的其他字段),如果不存在该电话号码,则数据库操作为“insert”。
在dreamweaver中生成相应的表单后(见下面的代码),再在dreamweaver中单击绑定->命令(预存过程),并选择SQL Server数据库中的上述存储过程后产生的代码如下:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/localserver.asp" -->
<%
var updatesub__kind = "";
if(String(Request("kind")) != "undefined"){ updatesub__kind = String(Request("kind"));}
var updatesub__notsale = "";
if(String(Request("notsale")) != "undefined"){ updatesub__notsale = String(Request("notsale"));}
var updatesub__sale = "";
if(String(Request("sale")) != "undefined"){ updatesub__sale = String(Request("sale"));}
var updatesub__salein2month = "";
if(String(Request("salein2month")) != "undefined"){ updatesub__salein2month = String(Request("salein2month"));}
var updatesub__direction12 = "";
if(String(Request("direction12")) != "undefined"){ updatesub__direction12 = String(Request("direction12"));}
var updatesub__price12 = "";
if(String(Request("price12")) != "undefined"){ updatesub__price12 = String(Request("price12"));}
var updatesub__lasthouse = "";
if(String(Request("lasthouse")) != "undefined"){ updatesub__lasthouse = String(Request("lasthouse"));}
var updatesub__news = "";
if(String(Request("news")) != "undefined"){ updatesub__news = String(Request("news"));}
var updatesub__phonenumber = "";
if(String(Request("phonenumber")) != "undefined"){ updatesub__phonenumber = String(Request("phonenumber"));}
%>
<%
var updatesub = Server.CreateObject("ADODB.Command");
updatesub.ActiveConnection = MM_localserver_STRING;
updatesub.CommandText = "dbo.update_subscribe";
updatesub.CommandType = 4;
updatesub.CommandTimeout = 0;
updatesub.Prepared = true;
updatesub.Parameters.Append(updatesub.CreateParameter("@RETURN_VALUE", 3, 4));
updatesub.Parameters.Append(updatesub.CreateParameter("@kind", 200, 1,21,updatesub__kind));
updatesub.Parameters.Append(updatesub.CreateParameter("@notsale", 901, 1,1,updatesub__notsale));
updatesub.Parameters.Append(updatesub.CreateParameter("@sale", 901, 1,1,updatesub__sale));
updatesub.Parameters.Append(updatesub.CreateParameter("@salein2month", 901, 1,1,updatesub__salein2month));
updatesub.Parameters.Append(updatesub.CreateParameter("@direction12", 200, 1,21,updatesub__direction12));
updatesub.Parameters.Append(updatesub.CreateParameter("@price12", 16, 1,1,updatesub__price12));
updatesub.Parameters.Append(updatesub.CreateParameter("@lasthouse", 901, 1,1,updatesub__lasthouse));
updatesub.Parameters.Append(updatesub.CreateParameter("@news", 901, 1,1,updatesub__news));
updatesub.Parameters.Append(updatesub.CreateParameter("@phonenumber", 200, 1,21,updatesub__phonenumber));
updatesub.Execute();
%>
表单的源码(绝对正确已经试过)省略
-------------------------
得到如下错误:
Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
ADODB.Command 错误 '800a0bb9'
变量或者类型不正确,或者不在可以接受的范围之内,要不就是与其他数据冲突。
/house/subscribe.asp,行43
行43为:updatesub.Parameters.Append(updatesub.CreateParameter("@notsale", 901, 1,1,updatesub__notsale));
------------------------------
由于对ASP/Javascript不是太熟悉,无法分析出错的原因。但是,似乎可以肯定的是dreamweaver不能完成以表单中输入的数据为变量的存储过程的自动RAD。
大虾求救!!!
谢谢了