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

  • 相关阅读:
    利用XShell上传、下载文件(使用sz与rz命令)
    我做的一个websocket的demo(php server)
    linux下如何实现mysql数据库每天自动备份定时备份
    php利用ob缓存机制实现页面静态化方法全解
    MySQL数据备份之mysqldump使用
    将jpg压缩成webp格式的图片
    ab网站压力测试命令的参数、输出结果的中文注解
    网页优化实例
    JQ 为未来元素添加事件处理器—事件委托
    Web前端优化最佳实践及工具集锦
  • 原文地址:https://www.cnblogs.com/catvi/p/1952964.html
Copyright © 2011-2022 走看看