I am writing a simple wrapper for sp calls using SqlCommand Type == StoredProcedure. I just want to pass the parameter there without specifying its name. How should I do it? cmd.Parameters.Add (param) does not work, it receives only an instance of SqlParameter. Thanks for answers,
How to try using SqlCommandBuilder.DeriveParameters to populate a collection of parameters?
Using:
// Create Command SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = storedProcedureName; // Open Connection connection.Open(); // Discover Parameters for Stored Procedure and populate command.Parameters Collection. // Causes Rountrip to Database. SqlCommandBuilder.DeriveParameters(command);
You will obviously need to fill in the values for each parameter.
AFAIK, ParameterName. , Enterprise Library, - :
Database db = DatabaseFactory.CreateDatabase("DatabaseName"); DbCommand cmd = new SqlCommand("SP Name Here"); cmd.CommandType = CommandType.StoredProcedure; db.DiscoverParameters(cmd);
Command .
Source: https://habr.com/ru/post/1786607/More articles:Can I free () by referencing the offset pointer? - cHow to get Wi-Fi information. in Android? - androidHow to install webMatrix on a machine without an internet connection? - webmatrixproblem with open android keyboard - androidClick Image Preview - Android - javaЗашифрованный файл openssl aes-256 на окнах не может быть расшифрован на linux - linuxHow to encrypt and decrypt a string in C # - c #.NET: what are my options for decrypting a password in my project .setting file - c #jQuery datepicker not working in IE7 and IE8 - javascriptHow to take a full snapshot of a web page? (scrollable size large) - phpAll Articles