当前位置: 首页>>代码示例>>C#>>正文


C# SqlCommand.SQLCommandTextDump方法代码示例

本文整理汇总了C#中System.Data.SqlClient.SqlCommand.SQLCommandTextDump方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCommand.SQLCommandTextDump方法的具体用法?C# SqlCommand.SQLCommandTextDump怎么用?C# SqlCommand.SQLCommandTextDump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlClient.SqlCommand的用法示例。


在下文中一共展示了SqlCommand.SQLCommandTextDump方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteSQLRetDS

 /// <summary>
 /// Выполить SQL запрос и вернуть DataSet
 /// </summary>
 /// <param name="_sql">SQL запрос</param>
 /// <returns>Исходящий DataSet</returns>
 public static DataSet ExecuteSQLRetDS(string _sql)
 {
     string InitString = "";
     if (Config.DBAuth.Login == null || Config.DBAuth.Login=="")
         InitString = "Data Source=" + Config.DBAuth.URL + ";Initial Catalog=" + Config.DBAuth.AuthToken + ";Trusted_Connection=true;Connect Timeout = 120;";
     else
         InitString = "Data Source=" + Config.DBAuth.URL + ";Initial Catalog=" + Config.DBAuth.AuthToken + ";User Id=" + Config.DBAuth.Login + ";Password=" + Config.DBAuth.Password + ";Connect Timeout = 120;";
     DataSet retval = new DataSet();
     using (var con = new SqlConnection(InitString))
     {
         using (var command = new SqlCommand(_sql, con) { CommandType = CommandType.Text })
         {
             try {
                 con.Open();
                 using (var da = new SqlDataAdapter(command))
                 {
                     da.Fill(retval);
                 }
                 con.Close();
             }
             catch (Exception _ex)
             {
                 TLogger.Add("TMSSQLConnector. EXCEPTION: " + _ex.Message + " SQL: " + command.SQLCommandTextDump(), TLogger.MSGType.eEmail);
                 throw _ex;
             }
         }
     }
     return retval;
 }
开发者ID:artemablitsov,项目名称:PPFSendII,代码行数:34,代码来源:TMSSQLConnector.cs

示例2: ExecuteProcRetString

 /// <summary>
 /// Выполнить SQL процедуру и вернуть первую строку
 /// </summary>
 /// <param name="_procname">Имя процедуры</param>
 /// <param name="_param">Массив параметров</param>
 /// <returns>Результат в виде строки</returns>
 public static string ExecuteProcRetString(string _procname, List<SqlParameter> _param = null)
 {
     string InitString = "";
     if (Config.DBAuth.Login == null || Config.DBAuth.Login == "")
         InitString = "Data Source=" + Config.DBAuth.URL + ";Initial Catalog=" + Config.DBAuth.AuthToken + ";Trusted_Connection=true;Connect Timeout = 120;";
     else
         InitString = "Data Source=" + Config.DBAuth.URL + ";Initial Catalog=" + Config.DBAuth.AuthToken + ";User Id=" + Config.DBAuth.Login + ";Password=" + Config.DBAuth.Password + ";Connect Timeout = 120;";
     string retval = "";
     using (var con = new SqlConnection(InitString))
     {
         using (var command = new SqlCommand(_procname, con) { CommandType = CommandType.StoredProcedure })
         {
             if (_param != null)
             {
                 foreach (var val in _param)
                 {
                     command.Parameters.Add(val);
                 }
             }
             try
             {
                 con.Open();
                 object ret = command.ExecuteScalar();
                 if (ret != null && ret != DBNull.Value)
                     retval = ret.ToString();
                 con.Close();
             }
             catch (Exception _ex)
             {
                 TLogger.Add("TMSSQLConnector. EXCEPTION: " + _ex.Message + " SQL: " + command.SQLCommandTextDump(), TLogger.MSGType.eEmail);
                 throw _ex;
             }
         }
     }
     return retval;
 }
开发者ID:artemablitsov,项目名称:PPFSendII,代码行数:42,代码来源:TMSSQLConnector.cs

示例3: ExecuteSQLCommand

 public static int ExecuteSQLCommand(SqlCommand _cmd)
 {
     string InitString = "";
     if (Config.DBAuth.Login == null || Config.DBAuth.Login == "")
         InitString = "Data Source=" + Config.DBAuth.URL + ";Initial Catalog=" + Config.DBAuth.AuthToken + ";Trusted_Connection=true;Connect Timeout = 120;";
     else
         InitString = "Data Source=" + Config.DBAuth.URL + ";Initial Catalog=" + Config.DBAuth.AuthToken + ";User Id=" + Config.DBAuth.Login + ";Password=" + Config.DBAuth.Password + ";Connect Timeout = 120;";
     int retval = -1;
     using (var con = new SqlConnection(InitString))
     {
         _cmd.Connection = con;
         try {
             con.Open();
             retval = int.Parse(_cmd.ExecuteScalar().ToString());
             con.Close();
         }
         catch (Exception _ex)
         {
             TLogger.Add("TMSSQLConnector. EXCEPTION: " + _ex.Message + " SQL: " + _cmd.SQLCommandTextDump(), TLogger.MSGType.eEmail);
             throw _ex;
         }
     }
     return retval;
 }
开发者ID:artemablitsov,项目名称:PPFSendII,代码行数:24,代码来源:TMSSQLConnector.cs

示例4: ExecuteProcRetDS

 /// <summary>
 /// Выполнить SQL процедуру и вернуть DataSet
 /// </summary>
 /// <param name="_procname">Имя процедуры</param>
 /// <param name="_param">Массив параметров</param>
 /// <returns>Исходящий DataSet</returns>
 public static DataSet ExecuteProcRetDS(string _procname, List<SqlParameter> _param = null)
 {
     string InitString = "";
     if (Config.DBAuth.Login == null || Config.DBAuth.Login == "")
         InitString = "Data Source=" + Config.DBAuth.URL + ";Initial Catalog=" + Config.DBAuth.AuthToken + ";Trusted_Connection=true;Connect Timeout = 120;";
     else
         InitString = "Data Source=" + Config.DBAuth.URL + ";Initial Catalog=" + Config.DBAuth.AuthToken + ";User Id=" + Config.DBAuth.Login + ";Password=" + Config.DBAuth.Password + ";Connect Timeout = 120;";
     DataSet retval = new DataSet();
     using (var con = new SqlConnection(InitString))
     {
         using (var command = new SqlCommand(_procname, con) {CommandType = CommandType.StoredProcedure})
         {
             if (_param!=null && _param.Count>0)
             {
                 foreach (var val in _param)
                 {
                     command.Parameters.Add(val);
                 }
             }
             try {
                 con.Open();
                 using (var da = new SqlDataAdapter(command))
                 {
                     da.Fill(retval);
                 }
                 con.Close();
             }
             catch (Exception _ex)
             {
                 TLogger.Add("TMSSQLConnector. EXCEPTION: " + _ex.Message + " SQL: " + command.SQLCommandTextDump(), TLogger.MSGType.eEmail);
                 throw _ex;
             }
         }
     }
     return retval;
 }
开发者ID:artemablitsov,项目名称:PPFSendII,代码行数:42,代码来源:TMSSQLConnector.cs


注:本文中的System.Data.SqlClient.SqlCommand.SQLCommandTextDump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。