Thulasiram pakala

Thulasiram pakala

  • 907
  • 872
  • 115.2k

i use this sql and C# code i want to display error message in lable in

Apr 29 2021 9:51 AM
i use this sql and C# code i want to display error message in lable in i get parameter count error what wrong in this query or code any body please help
  1. Alter Procedure [dbo].[Proc_ConsumermasterInsert]     
  2. (@DCM_DeptName  nvarchar(100),      
  3. @DCM_Address varchar(200),      
  4. @DCM_MobileNumber varchar(20),      
  5.  @DCM_CEOName varchar(50),        
  6. @DCM_EmailID varchar(50),      
  7. @DCM_DeptDescription varchar(200),      
  8. @DCM_AddedBy int,      
  9. @DCM_AddedIPAddress varchar(50),        
  10. @DCM_Remarks varchar(50),      
  11. @DCM_Abbrivation char(5),      
  12. @DCM_CategoryAgencyId int,        
  13. @DCM_ContactPersonName varchar(100),      
  14. @DCM_ContactPersonMobileNumber varchar(15),      
  15. @DCM_ContactPersonEmailID varchar(50),      
  16. @DCM_ContactPersonLandLineNumber varchar(20),    
  17. @ERROR varchar(500) =null    
  18. --@ERROR varchar(500) out     
  19. )  
  20. as begin    
  21. DECLARE @consumerid nvarchar(20)    
  22. DECLARE @getuid nvarchar(20)  
  23. begin try    
  24.    SET NOCOUNT ON  
  25. begin transaction                  
  26.   IF NOT EXISTS (SELECT DCM_ConsumerID FROM [DataConsumerMaster] WHERE DCM_DeptName =@DCM_DeptName)    
  27.    BEGIN    
  28.      
  29.    insert into [dbo].[DataConsumerMaster] (DCM_DeptName, DCM_Address, DCM_MobileNumber, DCM_CEOName, DCM_EmailID, DCM_DeptDescription,        
  30. DCM_DataConsumer, DCM_AddedOn, DCM_AddedBy, DCM_AddedIPAddress, DCM_Status,DCM_Remarks,DCM_EntryMode, DCM_Abbrivation,DCM_CategoryAgencyId,        
  31. DCM_ContactPersonName,DCM_ContactPersonMobileNumber,DCM_ContactPersonEmailID,DCM_ContactPersonLandLineNumber)        
  32. values(@DCM_DeptName, @DCM_Address, @DCM_MobileNumber, @DCM_CEOName, @DCM_EmailID, @DCM_DeptDescription,        
  33. 'A', getdate(), @DCM_AddedBy, @DCM_AddedIPAddress, 'A',@DCM_Remarks,'D',@DCM_Abbrivation,@DCM_CategoryAgencyId,        
  34. @DCM_ContactPersonName,@DCM_ContactPersonMobileNumber,@DCM_ContactPersonEmailID,@DCM_ContactPersonLandLineNumber)    
  35.    
  36.     Select  @consumerid  = SCOPE_IDENTITY();    
  37.       
  38.   set @getuid = (Select DCM_ConsumerID FROM DataConsumerMaster WHERE DCM_ID = @consumerid)     
  39.       
  40.   --Select @getuid= (Select UserName from  Logins where  Login_ID=@consumerid)    
  41.  --return @consumerid    
  42.  IF NOT EXISTS (Select * From Logins where Officer_Name=@DCM_CEOName)    
  43.  BEGIN    
  44.       
  45.     Insert into Logins(Password,UserName,Officer_Name,Officer_Mobile,Email_ID,Type_Of_User,Status,Date_of_Creation,created_by,Date_of_Modification,Roles)        
  46. Values('ov2FeiYRwvE=',Convert(nvarchar(50), @getuid) ,@DCM_CEOName,@DCM_MobileNumber,@DCM_EmailID,4,'Approved','',@DCM_AddedBy,'','C')    
  47. END    
  48.  commit transaction          
  49.  set @ERROR =@getuid    
  50.  --Print @consumerid    
  51. return @ERROR    
  52. End    
  53.   Rollback transaction    
  54.   set @ERROR ='User Id Allredy Genarated For this Department'    
  55.   return @ERROR   
  56.   end try  
  57.   begin catch          
  58.   if(@@trancount>0)      
  59.   begin        
  60.   set @ERROR = 'Error !' /*'Details Not Saved. Sorry For The Inconvinience.'*/      
  61. return @ERROR      
  62. end  
  63.   end catch                
  64. END  
  1. DataSet dsid = new DataSet();  
  2. SqlParameter[] arParamsOwners = null;  
  3. arParamsOwners = new SqlParameter[16];  
  4. arParamsOwners[0] = new SqlParameter("@DCM_DeptName", System.Data.SqlDbType.VarChar, 100);  
  5. arParamsOwners[0].Value = getObjMaster.ApplicationName;  
  6. arParamsOwners[1] = new SqlParameter("@DCM_Address", System.Data.SqlDbType.NVarChar, 100);  
  7. arParamsOwners[1].Value = getObjMaster.Address;  
  8. arParamsOwners[2] = new SqlParameter("@DCM_MobileNumber", System.Data.SqlDbType.NVarChar, 100);  
  9. arParamsOwners[2].Value = getObjMaster.MobileNumber;  
  10. arParamsOwners[3] = new SqlParameter("@DCM_CEOName", System.Data.SqlDbType.NVarChar, 500);  
  11. arParamsOwners[3].Value = getObjMaster.CeoName;  
  12. arParamsOwners[4] = new SqlParameter("@DCM_EmailID", System.Data.SqlDbType.NVarChar, 100);  
  13. arParamsOwners[4].Value = getObjMaster.EmailID;  
  14. arParamsOwners[5] = new SqlParameter("@DCM_DeptDescription", System.Data.SqlDbType.VarChar, 100);  
  15. arParamsOwners[5].Value = getObjMaster.ComapnyDescription;  
  16. arParamsOwners[6] = new SqlParameter("@DCM_AddedBy", System.Data.SqlDbType.NVarChar, 100);  
  17. arParamsOwners[6].Value = getObjMaster.approvedby;  
  18. arParamsOwners[7] = new SqlParameter("@DCM_AddedIPAddress", System.Data.SqlDbType.NVarChar, 500);  
  19. arParamsOwners[7].Value = getObjMaster.clientip;  
  20. arParamsOwners[8] = new SqlParameter("@DCM_Remarks", System.Data.SqlDbType.NVarChar, 100);  
  21. arParamsOwners[8].Value = getObjMaster.Remarks;  
  22. arParamsOwners[9] = new SqlParameter("@DCM_Abbrivation", System.Data.SqlDbType.NVarChar, 100);  
  23. arParamsOwners[9].Value = getObjMaster.Abbrivation;  
  24. arParamsOwners[10] = new SqlParameter("@DCM_CategoryAgencyId", System.Data.SqlDbType.NVarChar, 100);  
  25. arParamsOwners[10].Value = getObjMaster.Agencycategoryid;  
  26. arParamsOwners[11] = new SqlParameter("@DCM_ContactPersonName", System.Data.SqlDbType.NVarChar, 500);  
  27. arParamsOwners[11].Value = getObjMaster.PersonName;  
  28. arParamsOwners[12] = new SqlParameter("@DCM_ContactPersonMobileNumber", System.Data.SqlDbType.NVarChar, 100);  
  29. arParamsOwners[12].Value = getObjMaster.PersonMobileno;  
  30. arParamsOwners[13] = new SqlParameter("@DCM_ContactPersonEmailID", System.Data.SqlDbType.NVarChar, 100);  
  31. arParamsOwners[13].Value = getObjMaster.PersonEmailid;  
  32. arParamsOwners[14] = new SqlParameter("@DCM_ContactPersonLandLineNumber", System.Data.SqlDbType.NVarChar, 100);  
  33. arParamsOwners[14].Value = getObjMaster.Personlandline;  
  34. arParamsOwners[15] = new SqlParameter("@ERROR", System.Data.SqlDbType.NVarChar, 100);  
  35. arParamsOwners[15].Direction = ParameterDirection.Output;  
  36. // string message = arParamsOwners["@ERROR"].Value.ToString();  
  37. int Consumer=SqlHelper.ExecuteNonQuery(myConnectionString, "Proc_ConsumermasterInsert", arParamsOwners);  
  38. return Consumer;  

Answers (1)