Thanks a lot for your help, this worked out perfectly!
One more issue I am facing.
I am using a detailsview control to insert new rows in my DB. Right after I insert it, I want to grab the new row's value of the primary key to do something with it. This is an identity PK so I am not providing the value in the web page.
For this, I am using the SqlDataSource inserted event as follows:
protected void SqlDataSource2_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
string NewID = e.Command.Parameters["@ReviewID"].Value;
}
In order for this to work, I modified my SqlDataSource as follows:
To the insert query I appended this: ;SELECT @NewReviewID= @@Identity
So my query looks like this:
INSERT INTO [WineReviews] ([Winery], [Wine], [TypeID], [A], [BottleID], [SugarResidual], [Price], [Website], [Review], [Rating], [Notes], [TypeID2]) VALUES (@Winery, @Wine, @TypeID, @A, @BottleID, @SugarResidual, @Price, @Website, @Review, @Rating, @Notes, @TypeID2) ;SELECT @NewReviewID= @@Identity
Then I made sure that the ReviewID direction is "Output" and that the ReviewID is setup as a boundfield in the detailsview. However, I am sure I have something wrong.
When I try to insert, now I get this compilation error:
-----------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1955: Non-invocable member 'System.Data.Common.DbCommand.Parameters' cannot be used like a method.
-----------------
Thank you for helping me out. I am learning something new everyday creating this small test system
