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();
                }
            }
        }

  • 相关阅读:
    IOS之Block的应用-textFeild的回调应用
    KVC与KVO的不同
    git
    perl读取excel
    Linux用户管理
    Linux软件包的管理
    linux系统学习(二)
    linux系统学习(一)
    js模版渲染
    Discuz核心函数的解析
  • 原文地址:https://www.cnblogs.com/catvi/p/1952964.html
Copyright © 2011-2022 走看看