943,694 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 2525
  • C# RSS
Mar 10th, 2008
0

insert statement problem

Expand Post »
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:
C# Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
waterfall is offline Offline
24 posts
since Nov 2007
Mar 11th, 2008
0

Re: insert statement problem

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.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Mar 11th, 2008
0

Re: insert statement problem

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



C# Syntax (Toggle Plain Text)
  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
Reputation Points: 69
Solved Threads: 75
Posting Pro in Training
JerryShaw is offline Offline
465 posts
since Nov 2006
Mar 12th, 2008
0

Re: insert statement problem

my problem has been solved.i used update query instead of insert.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
waterfall is offline Offline
24 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Need design help for commission payout system
Next Thread in C# Forum Timeline: Print in client system





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC