同样的问题,给100分,求高手指点,在线等待............
用下面两种方式连接数据时,出现问题
1:用libary.udl文件方式 联接数据库函数为:
<%
'其中library.udl中放的是数据库的连接信息
function connect_db()
Set Conn = Server.CreateObject( "ADODB.Connection" )
Conn.Open "FILE NAME=E:\web\library\library.UDL"
connect_db=Conn
end function
%>
2:用以下方式联接
<%
function connect_db()
sqls = "Driver={SQL Server};
Server=192.168.0.102;
uid=library;
pwd=library;database=library"
Set conn = Server.CreateObject( "ADODB.Connection" )
conn.open sqls
connect_db=conn
end function
%>
结果在第一种方式时,在其它文件中调用connect_db()后
再调用SQL server上的存储过程时可以正常返回值。
用第二种方式调用connect_db()后
再调用SQL server上的存储过程却不能返回值正常值。
调用荐储过程的文件为:
Set CMD = Server.CreateObject( "ADODB.Command" )
Conn = connect_db()
CMD.ActiveConnection = Conn
CMD.CommandType = adCmdStoredProc
CMD.CommandText = "checkUser"
CMD.Parameters.Append CMD.CreateParameter( "returnStatus",adInteger, adParamReturnValue )
CMD.Parameters.Append CMD.CreateParameter( "username",adVarChar, adParamInput, 20, username )
CMD.Parameters.Append CMD.CreateParameter( "password",adVarChar, adParamInput, 20, password )
set RS=CMD.Execute
returnStatus = cINT( CMD( "returnStatus" ) )
CMD.ActiveConnection = Nothing
SET CMD = Nothing
response.write returnStatus
response.end
SQL Server上的存储过程为:
CREATE procedure checkUser
(
@username varchar(20),
@password varchar(20)
)
AS
if not exists( select login from userinfo where login = @username and password = @password and status = 0 )
begin
return( 20 )
end
else
begin
return( 10 )
end
用第一种方式时输出10
用第二种方式时输出0
请问高手是什么原因?
很急,请帮我,一定给分!!!!!!!急!!!!!!!!!!!
用第二种方式时,可以用
CMD.Execute("select .............")
方式直接在程序文件中调用,但却不能调用
存储过程,请指教...............................