I am using Visual Studio to create an asp.net web application in C# and am having issues trying to insert data from one of my pages into a table in a SQL Server database. I am getting the following error message:
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: The variable name '@' has already been declared. Variable names must be unique within a query batch or stored procedure.
My code looks like this;
I have tried a few different things but I keep getting the same error and I've been on here and youtube for nearly an hour now and I can't find anything that relates to my issue. Any help would be greatly appreciated.
Thanks!
Edit: I should add that I got this code from youtube and in the video, it worked fine. The only real difference is that my version is within an 'if' statement. I commented the if statement out and received the same error message.