```csharp
//CPublic.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
class CPublic
{
public static String LoginInfo;
public static void CheckUsers(string UserID, string Pwd)
{
//String abc;
LoginInfo = null;
SqlConnection cn = new SqlConnection(Properties.Settings.Default.test1ConnectionString);
SqlCommand mysqlcommand = cn.CreateCommand();
mysqlcommand.CommandText = "execute [dbo].[usp_Users_VeryLoginVerify] N'" + @UserID + "',N'" + @Pwd + "'";
cn.Open();
SqlDataReader myDataReader = mysqlcommand.ExecuteReader();
myDataReader.Read();
LoginInfo = myDataReader["User_name1"].ToString();
LoginInfo.Trim();
myDataReader.Close();
cn.Close();
}
}
}
------SQL存储过程 USE[test1]
GO
/****** Object: StoredProcedure [dbo].[usp_Users_VeryLoginVerify] Script Date: 04/27/2022 17:05:29 ******/SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
-- =============================================-- Author: <Author,,Name>-- Create date: <Create Date,,>-- Description: <Description,,>-- =============================================--CREATE PROCEDURE [dbo].[usp_Users_VeryLoginVerify] ALTERPROCEDURE[dbo].[usp_Users_VeryLoginVerify]-- Add the parameters for the stored procedure here@u_nbr NVARCHAR(20),@pwd NVARCHAR(100)ASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.--SET NOCOUNT ON;-- Insert statements for procedure hereDeclare@IsRight NVARchar(15)Declare@pvVARBINARY(MAX)Select@pv=[upassword]from[dbo].[Test3]where[username]=@u_nbr------解密if@pwd=CONVERT(NVARCHAR(100),DecryptByPassphrase('Ilovesqlserver',@pv))set@IsRight=@u_nbrSELECT@IsRightas User_name1
END