方法一































方法二:
1
public static AdoHelper helper = AdoHelper.CreateHelper("sqlDA");
2
public static string cs = WebConfigurationManager.AppSettings["SqlServerConnectionString"];
3
4
protected void Page_Load(object sender, EventArgs e)
5
{
6
IDataParameter[] parameters = helper.GetSpParameterSet(cs, "GetUName");
7
parameters[0].Value = 6;
8
parameters[1].Direction = ParameterDirection.Output;
9
IDataReader reader = helper.ExecuteReader(cs, "GetUName", parameters);
10
string data = (string)parameters[1].Value;
11
Response.Write(data);
12
13
14
}
15
16
存储过程
17
CREATE PROCEDURE GetUName
18
-- Add the parameters for the stored procedure here
19
(
20
@userid int,
21
@uname varchar(50) OutPut
22
)
23
AS
24
25
-- SET NOCOUNT ON added to prevent extra result sets from
26
-- interfering with SELECT statements.
27
SET NOCOUNT ON;
28
29
-- Insert statements for procedure here
30
SELECT @uname = UName from UserInfo where UserID = @userid
31
32
GO

2

3

4

5



6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

方法三:一个判断登陆
1
public static int VerifyPassword(string strUsername, string strPassword)
2
{
3
// IDataParameter[] parameters = helper.GetSpParameterSet(cs, "VerifyPassword");
4
IDataParameter[] parameters = new IDataParameter[3];
5
parameters[0] = helper.GetParameter("@username", strUsername);
6
parameters[1] = helper.GetParameter("@password", strPassword);
7
parameters[2] = helper.GetParameter("ReturnValue",DbType.Int16, 4, ParameterDirection.ReturnValue);
8
9
helper.ExecuteNonQuery(cs, "VerifyPassword", parameters);
10
return (int)parameters[2].Value;
11
}
12
存储过程
13
PROCEDURE [dbo].[VerifyPassword]
14
(
15
@username Varchar( 20 ),
16
@password Varchar( 20 )
17
--@reason int OutPut
18
)
19
AS
20
DECLARE @foundUser Varchar( 20 )
21
SELECT @foundUser = ul_username
22
FROM UserList
23
WHERE ul_username = @username
24
AND ul_password = @password
25
IF @foundUser IS NOT NULL
26
--set @reason =0
27
return 0
28
ELSE
29
IF Exists( SELECT ul_username
30
FROM UserList WHERE ul_username = @username )
31
--set @reason =2
32
return 2
33
ELSE
34
--set @reason = 1
35
return 1
36
37

2



3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37
