I am trying to access a stored procedure and I get an error message:
The procedure or function 'getbug' expects the parameter '@bugID', which was not provided.
This is my code to call the procedure.
SqlCommand cmd = new SqlCommand("getbug", cn); cmd.Parameters.Add(new SqlParameter("bugID", bugID));
bugID is set to 1089 (and is an int type)
I can’t understand why this will not work.
Try this instead
SqlCommand cmd = new SqlCommand("getbug", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@bugID", bugID));
Try adding the "@" parameter to the parameter
SqlCommand cmd = new SqlCommand("getbug", cn); cmd.Parameters.Add(new SqlParameter("@bugID", bugID));
. , .
, CommandType. , AddWithValue, .
CommandType
AddWithValue
using (var cn = new SqlConnection("your connection string")) { using (var cmd = new SqlCommand("getbug", cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@bugID", bugID); //etc... } }
Source: https://habr.com/ru/post/1739793/More articles:Использование бережливости с PHP и Java - javaConnecting a PHP frontend to an internal java service - javaExtract partial task from Symfony 1.4 - symfony1Conversion from hexadecimal to decimal conversion to C - cNSDecimalNumber - Breeding Strangeness - objective-cКак рассчитать количество рабочих дней между двумя датами? - datetimeИспользование бережливости для смешивания языков разработки - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1739796/box2dx-specify-fixtures-to-ignore-in-raycasting&usg=ALkJrhhEQInnkCY8fXbYdxnVNfmZaLzptwWhy should people use multiple versions of jQuery on the same page? - javascriptJQuery code to remove all spaces with one content, but one - javascriptAll Articles