输入不是有效的Base64字符串,因为它包含非基数64字符,

时间:2014-12-05 06:25:43

标签: c#

ALTER PROCEDURE [dbo].[InsertUpdatePartnerMasterDetailsandTemp] 
(@UserMasterId   INT,
@PartnerCode VARCHAR(100),
@PartnerName VARCHAR(100),
@PartnerEmailId VARCHAR(100),
@PartnerTypeId  INT,
@PartnerGroupId INT,
@LoginId VARCHAR(50),
@RegionId       INT,
@LocationId     INT,
@StateId INT,
@DistrictId INT,
@TalukaId INT,
@PincodeId INT, 
@Address VARCHAR(250),
@PartnerClass VARCHAR(50),
@CREATEDBY      INT,
@CREATEDBYIP VARCHAR(20),
@ERRORCODE   INT output,
@PasswordOut varchar(10) output,
@partnercodeid int output
)
AS
  BEGIN
      SET nocount ON

      --BEGIN try
      --    BEGIN TRANSACTION

          DECLARE @password VARCHAR(15),
                  @userid   INT,
                  @PartnerId INT,
                  @partnercodeauto int

          SET @password =(SELECT dbo.Ufn_generatepassword(10))
          SET @ERRORCODE = 0
          set @PasswordOut=@password
         -- set @partnercodeauto=(select PartnerCode from partnermaster where PartnerCode=@PartnerCode)
          ---set @partnercodeid=@partnercodeauto

          IF @UserMasterId = 0 --INSERT STARTS  
            BEGIN
                --IF EXISTS (SELECT loginid
                           --FROM   usermaster
                          -- WHERE  usermasterid <> @UserMasterId
                                 -- AND loginid = @LoginId)
                -- BEGIN
                     -- SET @ERRORCODE = 8

                    --  RETURN @ERRORCODE
                 -- END
                ----  
                --ELSE
                  BEGIN
                      -- 
                      IF EXISTS (SELECT partnercode
                                 FROM   partnermaster
                                 WHERE  usermasterid <> @UserMasterId
                                        AND partnercode = @PartnerCode)
                        BEGIN
                            SET @ERRORCODE =7
                            RETURN @ERRORCODE

                        END
                      ELSE
                        BEGIN
                      INSERT INTO usermaster
                                  (--loginid,
                                   --username,
                                   --partnercode,
                                   --emailid,
                                   password,
                                   tablename,
                                   isfirsttimelogin,
                                   Createddate,
                                   CreatedBy,
                                   CreatedByIp
                                   )
                      VALUES      (--@LoginId,
                                   --@PartnerName,
                                   --@PartnerCode,
                                   --@PartnerEmailId,
                                   @password,
                                   'p' ,
                                   1,
                                   getdate(),
                                   @CREATEDBY,
                                    @CREATEDBYIP  )

                       SET @userid = SCOPE_IDENTITY()


                      --SET @userid = (SELECT Max(usermasterid)
                                    -- FROM   usermaster)



                            INSERT INTO partnermaster
                                        (
                                        partnercode,
                                         partnername,
                                         partneremailid,
                                         partnertypeid,
                                         partnergroupid,
                                         regionid,
                                         locationid,
                                         StateId,
                                         TalukaId,
                                         DistrictId,

                                         PincodeId,
                                         address,
                                         partnerclass,
                                         approvalstatus,
                                         createdby,
                                         recstatus,
                                         createddate,
                                         createdbyip,
                                         usermasterid)
                            VALUES      ( 
                                          @PartnerCode,
                                          @PartnerName,
                                          @PartnerEmailId,
                                          @PartnerTypeId,
                                          @PartnerGroupId,
                                          @RegionId,
                                          @LocationId,
                                          @StateId,
                                          @TalukaId,
                                          @DistrictId,

                                          @PincodeId,                                          
                                          @Address,
                                          @PartnerClass,
                                          1,
                                          @CREATEDBY,
                                          0,
                                          Getdate(),
                                          @CREATEDBYIP,
                                          @userid )

                            SET @PartnerId = (select MAX(PartnerId) from partnermaster) 
                            PRINT @PartnerId  

                            INSERT INTO PartnerCodeAutoGeneration(PartnerId) values(@PartnerId)
                            UPDATE partnermaster SET partnercode=(select top 1 PartnerCodeAutoID from PartnerCodeAutoGeneration pca where pca.PartnerId =@PartnerId )
                            WHERE PartnerId=@PartnerId


                            DECLARE @MasterUserId   INT

                            SET @MasterUserId = (SELECT Max(usermasterid)
                                    FROM   usermaster)
                            UPDATE usermaster set LoginId=('PARTNER'+ Convert(varchar,(select top 1 PartnerCodeAutoID from PartnerCodeAutoGeneration pca where pca.PartnerId=@PartnerId))) where UserMasterId=@MasterUserId
                            set  @partnercodeid=(select PartnerCode from partnermaster pca where pca.PartnerId =@PartnerId )


                          --set  @partnercodeid=1

                          INSERT INTO userrolemapping
                                  (userid,
                                   roleid,
                                   createddate,
                                   createdby,
                                   createdbyip)
                      VALUES     (@userid,
                                  5,
                                  Getdate(),
                                  @CREATEDBY,
                                  @CREATEDBYIP )
                        END


                  END
                    IF @@ROWCOUNT = 0  
                    BEGIN  
                        SET @ERRORCODE = 99 -- DATA IS NOT INSERTED  
                    END  
                    RETURN @ERRORCODE 
            END --INSERT ENDS  
          ELSE
            BEGIN

                Declare @Partnermasterid int
                IF EXISTS (SELECT partnerid
                           FROM   partnermaster pm inner join usermaster um
                           on pm.usermasterid=um.usermasterid
                           WHERE  um.usermasterid = @UserMasterId
                                  )
                  BEGIN

                      SET @partnermasterid=(SELECT partnerid
                           FROM   partnermaster pm inner join usermaster um
                           on pm.usermasterid=um.usermasterid
                           WHERE  um.usermasterid = @UserMasterId)

                           IF EXISTS (SELECT loginid
                           FROM   usermaster
                           WHERE  usermasterid <> @UserMasterId
                                  AND loginid = @LoginId)
                              BEGIN
                                  SET @ERRORCODE = 7
                                  Print 'ddd';
                                  RETURN @ERRORCODE
                              END
                          ELSE 
                             IF EXISTS (SELECT partnercode
                                 FROM   partnermaster
                                 WHERE  usermasterid <> @UserMasterId
                                AND partnercode = @PartnerCode)
                                BEGIN
                                    SET @ERRORCODE =7
                                    PRINT 'FAIL'  
                                    RETURN @ERRORCODE

                                END


                             BEGIN  


                                update partnermaster set Approvalstatus=4 where  partnerid= @partnermasterid    
                                INSERT INTO dbo.PartnerTemptable
                                            (
                                             PartnerMasterId,
                                             partnercode,
                                             partnername,
                                             partneremailid,
                                             partnertypeid,
                                             partnergroupid,
                                             regionid,
                                             locationid,
                                             StateId,
                                             DistrictId,
                                             TalukaId,
                                             PincodeId,
                                             address,
                                             partnerclass,
                                             approvalstatus,
                                             createdby,
                                             recstatus,
                                             createddate,
                                             createdbyip,
                                             usermasterid)
                                VALUES      ( 
                                              @partnermasterid,
                                              @PartnerCode,
                                              @PartnerName,
                                              @PartnerEmailId,
                                              @PartnerTypeId,
                                              @PartnerGroupId,
                                              @RegionId,
                                              @LocationId,
                                              @StateId,
                                              @DistrictId,
                                              @TalukaId,
                                              @PincodeId,                                          
                                              @Address,
                                              @PartnerClass,
                                              4,
                                              @CREATEDBY,
                                              0,
                                              Getdate(),
                                              @CREATEDBYIP,
                                              @UserMasterId 

                                             )

                            set @ErrorCode =3
                            RETURN @ERRORCODE

                            END

                         END

            END

            RETURN @ERRORCODE

  END

我在应用程序中收到错误

  

输入不是有效的Base-64字符串,因为它包含非基本64个字符,两个以上的填充字符或填充字符中的非法字符。

调试代码时

。密码错误生成。由于我已将loginid更新为PARTNER+Partnercode。在更新之前,正确生成了loginid密码。但我的要求是我需要更新loginid。我也尝试过使用insert语句,密码生成错误。所以建议我这个。

0 个答案:

没有答案