//存储过程
/*if Exists(select name from sysobjects where name='addOneArticle' and type='P') drop procedure addOneArticle*/
/*if Exists(select name from sysobjects where name ='Session' and type='P') drop procedure Session*/
/* exec('drop procedure dbo.Session') */
use highway_test_new
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
if Exists(select id from dbo.sysobjects where id = object_id('dbo.Session') and type = 'P')
BEGIN
exec('drop procedure dbo.Session')
return
END
GO
CREATE PROCEDURE Session
@username varchar(50) ,@i_result INT OUTPUT
AS
BEGIN
DECLARE @v_sql varchar(200)
if object_id('tempdb.dbo.##user'+ @username) is null
begin
set @v_sql = 'create table ##user'+@username +'(username varchar(100))'
exec(@v_sql)
set @i_result = 0
end
else
set @i_result = 1
END
//
实现代码
bool VerifyUserLogin(TMSConnection* pConn,TMSStoredProc* ptsp,AnsiString strUserName)
{
if(pConn == NULL || ptsp == NULL)
return false;
ptsp->StoredProcName = "Session";
ptsp->Connection = pConn;
ptsp->ParamByName("@username")->AsString = strUserName;
ptsp->ExecProc();
int iRet ;
iRet = ptsp->ParamByName("@i_result")->AsInteger;
if(iRet == 1)//存在相同用户在登陆
{
return false;
}
else if(iRet == 0)
{
return true;
}
return false;
}