1. Create a stored procedure:
-- Create a stored procedure for login, if exists (select name from sys. sysobjects where name = 'loginproc ')
Drop procedure LoginProc
Go
Create procedure LoginProc (@ name varchar (100), @ password varchar (100 ))
As
If exists (select u. Name from dbo. MSUser u where u. Name = @ name and u. Password = @ password)
-- Note that the returned column name is value and the value is 1 or 0.
Select 1 as value
Else
Select 0 as value
2. Modify user. hbm. xml. Note that after the class, the name is defined casually, the return value is value, and the type is long.
</Class>
<SQL-query name = "LoginProceure">
<Return-scalar column = "value" type = "long"/>
Exec LoginProc ?,?
</SQL-query>
</Hibernate-mapping>
3. Execute the Stored Procedure
# Region execution Stored Procedure
Public IList ExecuteProcedure (string spName, string name, string pwd)
{
IList result = new ArrayList ();
Try
{
Return Session. GetNamedQuery (spName). SetString (0, name). SetString (1, pwd). List ();
}
Catch (Exception ex)
{
Throw ex;
}
Finally
{
Session. Flush ();
}
}
# Endregion
Object obj = il [0];
If (obj. ToString () = "1 ")
Return true;
Else
Return false;