problem with insert statement

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2007
Posts: 24
Reputation: waterfall is an unknown quantity at this point 
Solved Threads: 0
waterfall waterfall is offline Offline
Newbie Poster

problem with insert statement

 
0
  #1
Mar 10th, 2008
hi, im using VS.net 2005 for developing a web application.im using stored procedure for inserting records into database.i want to insert time and task for a selcetd employee but its not working. kindly help me.her's my stored procedure:
  1. create PROCEDURE [dbo].[AssignAndStore]
  2. -- Add the parameters for the stored procedure here
  3. @name varchar(50),
  4. @TaskAssigned nvarchar(50),
  5. @TimeAssigned nvarchar(50)
  6. AS
  7. BEGIN
  8. -- SET NOCOUNT ON added to prevent extra result sets from
  9. -- interfering with SELECT statements.
  10. SET NOCOUNT ON;
  11.  
  12.  
  13. --insert query
  14. insert into Employee(TaskAssigned,TimeAssigned)
  15. values (@TaskAssigned,@TimeAssigned)
  16. WHERE name = @name
  17. --im getting error with where clause
  18.  
  19. END
im using dropdwn list for task and name and textbox for time.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 206
Reputation: plazmo is an unknown quantity at this point 
Solved Threads: 16
plazmo's Avatar
plazmo plazmo is offline Offline
Posting Whiz in Training

Re: problem with insert statement

 
0
  #2
Mar 10th, 2008
You dont need a where for an insert because your not filtering out data, its a new record to the table. only an update, select or delete statements need a where clause.

You probably meant to do
update Employee
SET TaskAssigned=@TaskAssigned,
TimeAssigned=@TimeAssigned
WHERE name = @name

Also, id recommend assigning an identity ID to each employee and updating using the id
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 24
Reputation: waterfall is an unknown quantity at this point 
Solved Threads: 0
waterfall waterfall is offline Offline
Newbie Poster

Re: problem with insert statement

 
0
  #3
Mar 11th, 2008
thanx alot. it solved my problem.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC