@@ -33,7 +33,6 @@ public sealed partial class SqlCommand : DbCommand, ICloneable
3333 internal static readonly Action < object > s_cancelIgnoreFailure = CancelIgnoreFailureCallback ;
3434
3535 private _SqlRPC [ ] _rpcArrayOf1 = null ; // Used for RPC executes
36- private _SqlRPC _rpcForEncryption = null ; // Used for sp_describe_parameter_encryption RPC executes
3736
3837 // cut down on object creation and cache all these
3938 // cached metadata
@@ -1332,123 +1331,6 @@ private static int GetParameterCount(SqlParameterCollection parameters)
13321331 return parameters != null ? parameters . Count : 0 ;
13331332 }
13341333
1335- /// <summary>
1336- /// This function constructs a string parameter containing the exec statement in the following format
1337- /// N'EXEC sp_name @param1=@param1, @param1=@param2, ..., @paramN=@paramN'
1338- /// TODO: Need to handle return values.
1339- /// </summary>
1340- /// <param name="storedProcedureName">Stored procedure name</param>
1341- /// <param name="parameters">SqlParameter list</param>
1342- /// <returns>A string SqlParameter containing the constructed sql statement value</returns>
1343- private SqlParameter BuildStoredProcedureStatementForColumnEncryption ( string storedProcedureName , SqlParameterCollection parameters )
1344- {
1345- Debug . Assert ( CommandType == CommandType . StoredProcedure , "BuildStoredProcedureStatementForColumnEncryption() should only be called for stored procedures" ) ;
1346- Debug . Assert ( ! string . IsNullOrWhiteSpace ( storedProcedureName ) , "storedProcedureName cannot be null or empty in BuildStoredProcedureStatementForColumnEncryption" ) ;
1347-
1348- StringBuilder execStatement = new StringBuilder ( ) ;
1349- execStatement . Append ( @"EXEC " ) ;
1350-
1351- if ( parameters is null )
1352- {
1353- execStatement . Append ( ParseAndQuoteIdentifier ( storedProcedureName , false ) ) ;
1354- return new SqlParameter (
1355- null ,
1356- ( ( execStatement . Length << 1 ) <= TdsEnums . TYPE_SIZE_LIMIT ) ? SqlDbType . NVarChar : SqlDbType . NText ,
1357- execStatement . Length )
1358- {
1359- Value = execStatement . ToString ( )
1360- } ;
1361- }
1362-
1363- // Find the return value parameter (if any).
1364- SqlParameter returnValueParameter = null ;
1365- foreach ( SqlParameter param in parameters )
1366- {
1367- if ( param . Direction == ParameterDirection . ReturnValue )
1368- {
1369- returnValueParameter = param ;
1370- break ;
1371- }
1372- }
1373-
1374- // If there is a return value parameter we need to assign the result to it.
1375- // EXEC @returnValue = moduleName [parameters]
1376- if ( returnValueParameter != null )
1377- {
1378- SqlParameter . AppendPrefixedParameterName ( execStatement , returnValueParameter . ParameterName ) ;
1379- execStatement . Append ( '=' ) ;
1380- }
1381-
1382- execStatement . Append ( ParseAndQuoteIdentifier ( storedProcedureName , false ) ) ;
1383-
1384- // Build parameter list in the format
1385- // @param1=@param1, @param1=@param2, ..., @paramn=@paramn
1386-
1387- // Append the first parameter
1388- int index = 0 ;
1389- int count = parameters . Count ;
1390- SqlParameter parameter ;
1391- if ( count > 0 )
1392- {
1393- // Skip the return value parameters.
1394- while ( index < parameters . Count && parameters [ index ] . Direction == ParameterDirection . ReturnValue )
1395- {
1396- index ++ ;
1397- }
1398-
1399- if ( index < count )
1400- {
1401- parameter = parameters [ index ] ;
1402- // Possibility of a SQL Injection issue through parameter names and how to construct valid identifier for parameters.
1403- // Since the parameters comes from application itself, there should not be a security vulnerability.
1404- // Also since the query is not executed, but only analyzed there is no possibility for elevation of privilege, but only for
1405- // incorrect results which would only affect the user that attempts the injection.
1406- execStatement . Append ( ' ' ) ;
1407- SqlParameter . AppendPrefixedParameterName ( execStatement , parameter . ParameterName ) ;
1408- execStatement . Append ( '=' ) ;
1409- SqlParameter . AppendPrefixedParameterName ( execStatement , parameter . ParameterName ) ;
1410-
1411- // InputOutput and Output parameters need to be marked as such.
1412- if ( parameter . Direction == ParameterDirection . Output ||
1413- parameter . Direction == ParameterDirection . InputOutput )
1414- {
1415- execStatement . AppendFormat ( @" OUTPUT" ) ;
1416- }
1417- }
1418- }
1419-
1420- // Move to the next parameter.
1421- index ++ ;
1422-
1423- // Append the rest of parameters
1424- for ( ; index < count ; index ++ )
1425- {
1426- parameter = parameters [ index ] ;
1427- if ( parameter . Direction != ParameterDirection . ReturnValue )
1428- {
1429- execStatement . Append ( ", " ) ;
1430- SqlParameter . AppendPrefixedParameterName ( execStatement , parameter . ParameterName ) ;
1431- execStatement . Append ( '=' ) ;
1432- SqlParameter . AppendPrefixedParameterName ( execStatement , parameter . ParameterName ) ;
1433-
1434- // InputOutput and Output parameters need to be marked as such.
1435- if (
1436- parameter . Direction == ParameterDirection . Output ||
1437- parameter . Direction == ParameterDirection . InputOutput
1438- )
1439- {
1440- execStatement . AppendFormat ( @" OUTPUT" ) ;
1441- }
1442- }
1443- }
1444-
1445- // Construct @tsql SqlParameter to be returned
1446- SqlParameter tsqlParameter = new SqlParameter ( null , ( ( execStatement . Length << 1 ) <= TdsEnums . TYPE_SIZE_LIMIT ) ? SqlDbType . NVarChar : SqlDbType . NText , execStatement . Length ) ;
1447- tsqlParameter . Value = execStatement . ToString ( ) ;
1448-
1449- return tsqlParameter ;
1450- }
1451-
14521334 // paramList parameter for sp_executesql, sp_prepare, and sp_prepexec
14531335 internal string BuildParamList ( TdsParser parser , SqlParameterCollection parameters , bool includeReturnValue = false )
14541336 {
0 commit comments