日期:2014-05-20  浏览次数:20791 次

急,高手请进,!! 程序中在执行一段代码的时候数据库出现死锁,。
本帖最后由 mr_cheung 于 2011-10-23 21:47:54 编辑 C# 在查询某条数据时出现死锁,超时情况。
一下是查询数据库方法 C#代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace WindowsFormsApplication1
{
    class DBHelpSQL
    {
        static string stsqlcon = "Data Source=10.2.103.10;Initial Catalog=Testhis;User ID=sa";
        //static string stsqlcon = "Data Source=127.0.0.1;Initial Catalog=ErrorMechanismDB;User ID=sa;pwd=95688859";
        static SqlConnection sqlcon = null;

        #region 访问数据库- 服务方法

        /// <summary>
        /// 访问数据库-- 双向语句 (执行 Select 查询操作)
        /// </summary>
        /// <param name="strsqlTow"></param>
        /// <returns></returns>
        public static DataSet GetDateSet(string strsqlTow)
        {

            Open(); //连接串
            //利用数据适配器将数据从数据库填充到DataSet中
            SqlDataAdapter sda = new SqlDataAdapter(strsqlTow, sqlcon);
           /// sda.SelectCommand.CommandTimeout = 3600;
            DataSet ds = new DataSet();
           //开始填充数据到ds中的表temp中
           sda.Fill(ds, "temp");
            Close();
            return ds;
        }
        public static DataTable GetDateTable(string strsqlTow)
        {
            Open(); //连接串
            DataTable DT = new DataTable();
            SqlDataAdapter myCommand = new SqlDataAdapter(strsqlTow, sqlcon);

            DataSet ds = new DataSet();
            myCommand.Fill(ds);

            DT = ds.Tables[0];
            myCommand.Dispose();
            ds.Dispose();
            sqlcon.Close();
            Close();