當前位置:首頁 > 資訊 > info6 > 正文

SQL output用法學習心得

發表于: 2010-01-20   作者:chduguxue   來源:轉載   瀏覽:
摘要: [email protected](50)=null,@AdminPasswordnvarchar(50)=null,@LoginStateintoutputASifexists(SELECT*FROM[Admin][email protected][email protected]='1'

ALTER PROCEDURE dbo.Login @AdminName nvarchar(50)=null, @AdminPassword nvarchar(50)=null, @LoginState int output AS if exists (SELECT * FROM [Admin] WHERE [email protected] and [email protected] and State='1')--這個State是用來表示該用戶是否被禁用 set @LoginState=1 --登錄成功 else set @LoginState=0 --登錄失敗

 

string connStr = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString; SqlConnection con = new SqlConnection(connStr); con.Open(); SqlCommand thisCommand = new SqlCommand("Login", con); thisCommand.CommandType = CommandType.StoredProcedure; thisCommand.Parameters.Add("@AdminName", SqlDbType.NVarChar, 50).Value =AdminNameText.Text.Trim(); thisCommand.Parameters.Add("@AdminPassword", SqlDbType.Char, 200).Value = PasswordText.Text.Trim(); thisCommand.Parameters.Add("@LoginState", SqlDbType.Int); thisCommand.Parameters["@LoginState"].Direction = ParameterDirection.Output; thisCommand.ExecuteNonQuery(); Object objTempRole = thisCommand.Parameters["@LoginState"].Value; LoginLabel.Text = objTempRole.ToString();

SQL output用法學習心得

版權所有 IT知識庫 CopyRight ? 2009-2015 IT知識庫 IT610.com , All Rights Reserved. 京ICP備09083238號
广东25选5开奖结果