日期:2014-05-17 浏览次数:20395 次
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[ActivedCode]
(
@checkcode nvarchar(4000),
@UserName nvarchar(4000),
@t int
)
AS
IF @t=0 --写入激活码
BEGIN
insert into [CheckCode] (UserName,CheckCode) Values ('' + @UserName + '',''+ @checkcode + '')
END
ELSE --激活帐户
BEGIN
--判断激活码是否已经使用了
declare @c int
declare @sqls nvarchar(4000)
set @sqls='select @a=Count(*) From [CheckCode] Where CheckCode =''' + @checkcode + ''' and isUsed=0'
exec sp_executesql @sqls,N'@a int output',@c output
if @c=1
BEGIN
--首先将激活码的状态改为已经使用
Update [CheckCode] Set IsUsed=1 Where CheckCode = @checkcode
--激活帐户
Update [Users] Set isLock=0 Where UserName = @UserName
END
END
//激活帐户
public string ActivePassport(string UserName, string ActiveCode)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConnectionString();
string s;
//s = false;
try
{
conn.Open();
DataSet ds = new DataSet();
SqlCommand u = new SqlCommand();
u.Connection = conn;
u.CommandType = CommandType.Text;
u.CommandText = "ActivedCode";//调用存储过程
u.Connection = conn;
u.CommandType = CommandType.StoredProcedure;
var _with1 = u.Parameters;
_with1.AddWithValue(