Link to home
Start Free TrialLog in
Avatar of Shepwedd
Shepwedd

asked on

How do I insert data into my linq datacontext using a stored procedure?

I have two asp.net 3.5 listview controls on seperate pages. When a user clicks a link from the first listview I am passing an int ID variable (TrustID) through the query string to populate the second listview. I want to be able to insert new data into this list view using a stored procedure within my datacontext. I have attached the stored procedure (code below) to my datacontext and declared it within the insert properties of the appropriate table within my datacontext. I keep getting an out of range datetime error upon insert so I'm not too sure if my insert stored procedure is written correctly? "TrustID" is the foreign key in the TrustAccounts table used to pull through data attached to another table.
ALTER PROCEDURE proc_InsertTrustAccount
	(
	@TrustID int,
	@DueDate datetime,
	@FrequencyCode int,
	@ActionCode int,
	@Notes nvarchar(MAX)
	)	
AS
	Insert into TrustAccounts (TrustID, DueDate, FrequencyCode, ActionCode, Notes)
	Values (@TrustID, @DueDate, @FrequencyCode, @ActionCode, @Notes)
 
RETURN

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shepwedd
Shepwedd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial