insert statement problem

Please support our C# 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

insert statement problem

 
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 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: insert statement problem

 
0
  #2
Mar 11th, 2008
I don't have something in which I can say that's the problem I am not sure but try to be sure from column names like 'name'.
Trace the parameters sent to this SP if it works!
Send me the error raised to help you.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 436
Reputation: JerryShaw is on a distinguished road 
Solved Threads: 72
JerryShaw JerryShaw is offline Offline
Posting Pro in Training

Re: insert statement problem

 
0
  #3
Mar 11th, 2008
I tried answering this morning, but the network connection failed. Sorry for being late

The Insert statement does not allow a Where clause.
I will assume that your Employee table has a column named "EmployeeName" or some place to put the name value. It would not make sense to place a task against an employee without also telling the database which employee the task is assigned.

I have revised the proc for you below.

Regards,
Jerry



  1. create PROCEDURE [dbo].[AssignAndStore]
  2. @name varchar(50),
  3. @TaskAssigned nvarchar(50),
  4. @TimeAssigned nvarchar(50)
  5. AS
  6. BEGIN
  7.  
  8. insert into Employee(EmployeeName,TaskAssigned,TimeAssigned)
  9. values (@name,@TaskAssigned,@TimeAssigned)
  10.  
  11. END
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: insert statement problem

 
0
  #4
Mar 12th, 2008
my problem has been solved.i used update query instead of insert.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC