Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Alter Procedure approve   
(    
@leaveid int,    
@status int,
@userid int  
 )    
AS    
begin     
update leaves set status=@status where contentid=@leaveid    
  
declare    @applydate varchar(50), @applyiedby varchar(50), @isrmapproved varchar(50), @rmapproveddate varchar(50),@rmapprovedby varchar(50),@approvedby varchar(50),@ismanagerapproved varchar(50) ,@approvedate varchar(50) ,@iscancelled  varchar(20), @modifieddate varchar(50) , @modifiedby varchar(50)  
insert into reportingperosnreport    
(empid,leaveid,status,applydate,applyiedby,isrmapproved,rmapproveddate,rmapprovedby,ismanagerapproved,approvedate,  
approvedby,iscancelled,modifieddate,modifiedby)  
values   
('select employeeid from leaves where contentid=@leaveid' ,   
'@leaveid',  
'select status from leaves where contentid=@leaveid',  
'select createdate from leaves where content_id=@leaveid',  
'select Contentid from leaves where content_id=@leaveid',  
'select employee_id from Employee where =@userid',   
'getdate()',  
'select content_id from employee where content_id=@leaveid',  
'select status from leaves where contentid=@leaveid',  
'getdate()',  
'select employeeid from leaves where content_id=@userid',  
'select employeeid from leaves where content_id=@userid',  
'getdate()',  
'select employeename from employee where content_id=@userid')  
end


and i am not able to insert the data insert the table
C#
public int getdashboardapprove(int contentid ,int status,int leaveid)
    {
        openconnection();
        _com.CommandType = CommandType.StoredProcedure;
        _com.CommandTimeout = 2;
        _com.CommandText = "approve";
        _com.Parameters.AddWithValue("@status", status);
        _com.Parameters.AddWithValue("@leaveid", leaveid);
        _com.Parameters.AddWithValue("@userid", contentid);
        int result= com.ExecuteNonQuery(); ----->there is the error coming 
        con.Close();
        return result;
        }

tell me what to do now
Posted
Updated 19-Sep-13 0:58am
v3
Comments
Dholakiya Ankit 19-Sep-13 5:55am    
line no of error pls

1 solution

Hi,
delete the ' around your selects, now you are trying to insert the string 'select employeename from employee where content_id=@userid' into the column modifiedby, and that column can't take the 61 character.
Have a nice day

Hi, use an Insert with a Select:

SQL
Alter Procedure approve   
(    
@leaveid int,    
@status int,
@userid int  
 )    
AS    
begin     
update leaves set status=@status where contentid=@leaveid    


insert into reportingperosnreport    
(empid,leaveid,status,applydate,applyiedby,isrmapproved,rmapproveddate,rmapprovedby,ismanagerapproved,approvedate,  
approvedby,iscancelled,modifieddate,modifiedby)  
SELECT 
ll.employeeid, @leaveid, ll.status,...,e.employeename
FROM leaves ll, leaves lu, Employee e
WHERE ll.contentid=@leaveid AND lu.content_id=@userid AND e.content_id=@leaveid

END
 
Share this answer
 
v2
Comments
[no name] 19-Sep-13 7:19am    
where to do
[no name] 19-Sep-13 11:38am    
please let me know the complete answer so that it will be very help to me
Love 2 code 19-Sep-13 11:45am    
So you just have to fill in the corresponding column names in the Select

SELECT
ll.employeeid, @leaveid, ll.status,(use columns from tables ll, lu and e or getdate()),e.employeename
[no name] 20-Sep-13 3:38am    
it is not working so i have define it as repeating of insert into statements
Love 2 code 20-Sep-13 5:39am    
Ok, what is not working, what insert statement did you try?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900