0

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();
2
  • 2
    Unless you can provide some details we can't help. All you have said is "my code has an error". I assume you have a procedure or function called "getpopteam" and it has some parameters. I suspect you are not passing it a value for @tname. Commented Aug 13, 2014 at 14:24
  • It wants a parameter called @tname, not one called tname. Commented Aug 13, 2014 at 14:36

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.