Results 1 to 2 of 2

Thread: Error in inserting values into database

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    32

    Error in inserting values into database

    Hi..

    Am using stored procedure in my project, am trying to insert combo box values into the project, it is inserting value into the table but not to the proper column.. And i ve mention proper column name also in a Query.. Stored procedure code is like dis..
    Code:
    CREATE Procedure usp_liTeIn(@sku varchar(64),@dt char(10),@type char(1),@adSlNo int,@EnqFor char(2),@AdSlNoFor int,@Enquiry varchar(1000),@CuEnqNo varchar(64),@CEDt char(10),@Worth numeric(12,2),@HandBy int,@TargetDt Char(10),@EpSlNo int,@UsSlNo int,@slno int,@SpName varchar(100)= null)  as
    
    Begin
         Declare @numrows int,@errno int,@errmsg   varchar(255), @error int,@date datetime,@CuEnqDt dateTime,@tDt DateTime,@MaxId int
            
          SET NOCOUNT ON 
          SET DATEFORMAT MDy
          SET @date    = @Dt
          SET @CuEnqDt = @CEDt
          SEt  @TDt         = @TargetDt
                
    
    
          
             EXECUTE usp_GenerateID 'tEnquiry','TeSlNo',@MaxID OUTPUT 	
            
            if @MaxID <= 0
    	  begin  
                 select @error = 40000, @errmsg = 'Error On Key Generation ' + 			  convert(char(10),@errno) 
                 goto error  	  
            End 
    
            /* Insert a new record into TEnquiry Table */
    
            Insert TEnquiry (TeSlNo,TeSku,TeDate,TeType,TeAdSlNo,TeEnqFor,TeAdSlNoFor,TeEnquiry,TeCuEnqNo,TeCuEnqDt,TeEntDt,TeUpDt,teStatus,TeWorth,TeHandBy,TeTargetDt,TeEpSlNo,TeUsSlNo,TeSpName) 
            values (@MaxId,@Sku,@Date,@Type,@adSlno,@EnqFor,@AdSlNoFor,@Enquiry,@CuEnqNo,@CuEnqDt,getDate(),getDate(),'',@Worth,@HandBy,@tDt,@EpSlNo,@UsSlNo,@SpName)
            
            Select @numrows = @@rowcount,@errno = @@error                 
    	if @errno <> 0 or @numrows = 0 
    	   begin  	     
                 select @error = 30000, @errmsg = 'Error On Insert ' + convert(char(10),@errno) 
                 goto error  	  
            End
    
    
    end
    return 0
    /*  errors handling  */ 
    error:
      Begin 
        raiserror @error @errmsg     
        rollback  transaction 
        return   
    end
    GO
    Here am trying to insert value into TeSpName column but it is inserting into TeEpSlNo column.. help me..

  2. #2
    Lively Member
    Join Date
    Apr 2010
    Posts
    105

    Re: Error in inserting values into database

    Have you tried PRINT'ing out the value of @EpSlNo? Perhaps it's receiving the same value as @SpName?
    I wrote a book Visual Studio 2008 Programming
    Amazon.com / Visual Studio 2008 Programming / By Jamie Plenderleith & Steve Bunn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width