C # in the process of storage access method

Author:Anonymous    Updated:2008-2-27 21:39:43
Because generally used to execute T-SQL database operation, and occasionally now go with storage process, it does not write call to the return value of the process, and examine a lot of information, not detailed, or not the point, perhaps I am more stupid, huh.

C # source code
  1 / / / <summary>
  2 / / / check users
  3 / / / </ summary>
  4 / / / <param name="user"> user information </ param>
  5 / / / <returns> </ returns>
  6 public static int VerifyUser (clsUser user)
  7 (
  8 int iRet;
  9 string sql = String.Format ( "EXECUTE VerifyUser @ myVerifyReader OUTPUT, '}','{ 1) (0,'" user.username, user.password); / / implementation of the T-SQL string
10 SqlCommand scmd new SqlCommand = (sql, conn);
11 scmd.Parameters.Add (new SqlParameter ( "@ myVerifyReader" SqlDbType.Int));
12 scmd.Parameters [ "@ myVerifyReader"]. Direction = ParameterDirection.Output;
13 / /
14
15 DBOpen (conn);
16 / / return values on the issues
17 scmd.ExecuteNonQuery ();
18 iRet = (int) scmd.Parameters [ "@ myVerifyReader"]. Value;
19 DBClose (conn);
20 return iRet;
21)
SQL SERVER storage process
------------------------------


/ *
* VerifyUser storage process
* Uses: authenticate users landing
* /
CREATE PROCEDURE VerifyUser
(
     @ MyVerifyReader int OUTPUT, - Return result
     @ Username varchar (50), - User
     @ Userpassword varchar (50) - User Password
)
AS
IF EXISTS (SELECT FROM [id] [Users] WHERE username = @ @ = username AND userpassword userpassword)
     SET @ myVerifyReader = 0 - validated

ELSE IF EXISTS (SELECT FROM [id] [Users] WHERE username = @ username)
     SET @ myVerifyReader = 1 - the user exists, password is not correct
ELSE
     SET @ myVerifyReader = 2 - the user does not exist

RETURN isnull (@ myVerifyReader, 3)
-------------------------------------------------
GO
Previous:C# 3.0 LINQ query syntax
Next:Programming with C # literacy Binary
User Reviews
Related Articles
Recommended article
AD