Exemplo n.º 1
0
    public int fGetExistUserName(string oldUserName, string newUserName)
    {
        int exist = 0;

        Data.OPEN_CONNECTION(Data.CONECTION);
        Data.CMD = new System.Data.SqlClient.SqlCommand("DECLARE @exist INT " +
                                                        "if exists (select top 1 * from dbo.[CONFIG_USER] c where c.[UserName]= '" + newUserName + "' and c.[UserName] <> '" + oldUserName + "' )" +
                                                        "SET @exist = 1 " +
                                                        "ELSE " +
                                                        "SET @exist = 0 " +

                                                        "SELECT @exist AS EXIST", Data.CNN);
        Data.SQLDR = Data.CMD.ExecuteReader();

        while (Data.SQLDR.Read())
        {
            exist = int.Parse(Data.SQLDR[0].ToString());
        }

        return(exist);
    }//fin de la funcion