Print sqlcommand and sqlparameter parameters/Write SQL Params

Source: Internet
Author: User
A few days ago, the previous SQL Execution operations were switched to the sqlhelper operation method.
For convenience of debugging, the printing method of paramssql is customized.
After Params is passed and executed, you can call the following method to print the Params and value values.
SQL Params of sqlclient can be printed.
Applog is a custom debugging class.
You can switch to console. writeline/response. Write and other printing debugging methods. This makes it easy to understand the procedure execution process,
You don't need to debug the tracing.

Write_paramssql # Region Write_paramssql
/**/ ///   <Summary>
/// Write_paramssql
///   </Summary>
///   <Param name = "myparams"> </param>
///   <Param name = "strprocedurename"> </param>
Public   Static   Void Write_paramssql (sqlparameter [] myparams, string strprocedurename)
{
String logsql =   "" ;
For ( Int I =   0 ; I < Myparams. length; I ++ )
{< br> logsql + = myparams [I]. parametername + " = ' " + myparams [I]. value. tostring () + " ', \ n " ;
}
Applog. Log ( " Execute "   + Strprocedurename +   "   "   + Logsql );
}
/**/ ///   <Summary>
/// Write_paramssql
///   </Summary>
///   <Param name = "mycommand"> </param>
///   <Param name = "strprocedurename"> </param>
Public   Static   Void Write_paramssql (sqlcommand mycommand, string strprocedurename)
{
String logsql =   "" ;
For ( Int I =   0 ; I < Mycommand. Parameters. Count; I ++ )
{
Logsql + = Mycommand. Parameters [I]. parametername +   " =' "   + Mycommand. Parameters [I]. value. tostring () +   " ', \ N " ;
}
Applog. Log ( " Execute "   + Strprocedurename +   "   "   + Logsql );
}
# Endregion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.