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

  • 相关阅读:
    100%解决XP系统asp http500内部错误[转自XX博客]
    .net使用DotNetCharting控件生成报表统计图总结 (转地址)
    关于request取中文字符串变?的解决办法
    Delete删除大批量数据无响应的解决办法
    点击GridView模版列里的按钮取GridView当前被操作行的数据(转载)
    繁體字顯示問題
    寫博客過程中遇到的問題
    box model相關的API
    Buddhism常用術語
    靡不有初鮮克有終
  • 原文地址:https://www.cnblogs.com/catvi/p/1952964.html
Copyright © 2011-2022 走看看