zoukankan      html  css  js  c++  java
  • 两个数据库使用函数,比较简单

    主要是没有用那些现成的东西,而且可以设置timeout时间 

     protected DataSet execString(string sqlString)
        {
            SqlConnection CDOSuiteConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["CDOSuiteConnectionString"].ConnectionString);
            try
            {
                CDOSuiteConnection.Open();
                SqlCommand sqlCmd = new SqlCommand(sqlString, CDOSuiteConnection);
                sqlCmd.CommandType = System.Data.CommandType.Text;
                sqlCmd.CommandTimeout = 7200;
                SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                return ds;
            }
            finally
            {
                if (CDOSuiteConnection != null)
                {
                    CDOSuiteConnection.Close();
                }
            }
        }
        protected void execNonQuery(string sqlString)
        {
            SqlConnection CDOSuiteConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["CDOSuiteConnectionString"].ConnectionString);
            try
            {
                CDOSuiteConnection.Open();
                SqlCommand sqlCmd = new SqlCommand(sqlString, CDOSuiteConnection);
                sqlCmd.CommandType = System.Data.CommandType.Text;
                sqlCmd.CommandTimeout = 7200;
                sqlCmd.ExecuteNonQuery();
            }
            finally
            {
                if (CDOSuiteConnection != null)
                {
                    CDOSuiteConnection.Close();
                }
            }
        }

  • 相关阅读:
    【车】汽车X40保养
    【Teradata SQL】使用SQL将多个逗号分隔改为一个逗号分隔
    【Teradata】并行操作工具
    【Linux常见问题】SecureCRT 终端连接密钥交换失败错误
    【Linux基础】Linux更改系统IP
    【Teradata】块压缩(ferret工具)
    【Teradata】grouping和rollup窗口函数
    HttpClient之EntityUtils工具类
    MYSQL索引优化之单表示例
    MySQL执行计划示例
  • 原文地址:https://www.cnblogs.com/catvi/p/1952964.html
Copyright © 2011-2022 走看看