tallion

OutputSqlToConsole

Mar 4th, 2014
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.93 KB | None | 0 0
  1.     ''' <summary>
  2.     ''' TEST USE ONLY. Updates the pass in query by replacing the variables with their respective values from the parameter collection. Query is then outputed to the Immiediate window
  3.     ''' </summary>
  4.     ''' <param name="Sql"></param>
  5.     ''' <param name="Params"></param>
  6.     ''' <Created>'19.04.00 RI:xxxx CARRP02 02/21/2012</Created>
  7.     ''' <History></History>
  8.     ''' <remarks>use this for queries that have the variables parameterized</remarks>
  9.     Public Sub OutputSqlToConsole(Sql As String, Params As SqlClient.SqlParameterCollection)
  10.  
  11.         Try
  12.             For Each SqlParam As SqlClient.SqlParameter In Params
  13.                 Sql = Sql.Replace(SqlParam.ParameterName, SqlParam.Value)
  14.             Next
  15.  
  16.             Console.WriteLine(Sql)
  17.         Catch ex As Exception
  18.             'this method is only used for debuging so it should not crash the app if used inappropriately
  19.         End Try
  20.  
  21.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment