Reputation: 55
I have a stored procedure which inserts data from a web form to a table in my database.
During the execution an error popped up such as "Procedure or function 'getpopteam' expects parameter '@tname', which was not supplied", but when I entered into the my table in the db, all the values inserted in the web form is present in the db.
I executed it again and above mentioned error popped up again and all the values are successfully inserted into the database. I don't know what the problem is.
I'm using Visual Studio 2012 and SQL Server 2008
datacon();
con.Open();
SqlCommand cmd = new SqlCommand("getpopteam", con);
cmd.Parameters.Add(new SqlParameter("tname", txtteamname.Text));
cmd.Parameters.Add(new SqlParameter("usermail", txtemails.Text));
cmd.Parameters.Add(new SqlParameter("userpwd", txtpasswords.Text));
cmd.Parameters.Add(new SqlParameter("usercountry", countrydd.SelectedValue));
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
con.Close();
Upvotes: 0
Views: 115
Reputation: 96
Instead of typing string value of "tname", try prepending with the "@" symbol instead like this...
cmd.Parameters.Add(new SqlParameter("@tname", txtteamname.Text))
Hope this helps.
Upvotes: 1