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

  • 相关阅读:
    亚马逊产品图片爬取
    页面浏览统计之(一) hitcount
    页面浏览统计之(二) tracking
    页面浏览统计之(三) tracking2
    Django CMS apphooks – 使用应用钩子来添加主题应用
    Django CMS 插件 – 添加博客专题
    [整理] Windows下打印网页
    CompletableFuture详解
    详解JVM常量池、Class、运行时、字符串常量池
    分库分表总结
  • 原文地址:https://www.cnblogs.com/catvi/p/1952964.html
Copyright © 2011-2022 走看看