Example #1
0
        // 数据库命令的维护 - 打开数据集
        public bool rsOpen(ref System.Data.DataSet dst, string pSQL)
        {
            bool blnResult;

//
            if (dst == null)
            {
                dst = new System.Data.DataSet();
            }

            // 清控原来的数据
            dst.Clear();
            if (dst.Tables.Count > 0)
            {
                dst.Tables[0].Columns.Clear();
            }

            try
            {
                // del 2002-12-18
                //this.DisConnect();
                // endd

                // 连接
                if (blnResult = Connect())
                {
                    // 填充数据
                    new System.Data.SqlClient.SqlDataAdapter(pSQL, this.Connection).Fill(dst);

                    blnResult = dst.Tables.Count > 0;
                }
            }
            catch (System.Exception ee)
            {
                blnResult = false;

                if (this.Debug)
                {
                    U_Pub_Zwd.ErrorMessage("数据集打开错误:" + ee.Message);
                }
            }
            finally
            {
                // 断开
                // del 2002-12-18
                //DisConnect();
                // endd
            }

            return(blnResult);
        }
Example #2
0
        // 数据库命令的维护 - 执行命令
        public bool SQLExecute(string pSQL)
        {
            bool blnResult;

            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(pSQL, this.Connection);

            // add 2003-06-05
            cmd.CommandTimeout = 300;
            // enda

            try
            {
                // del 2002-12-18
                //this.DisConnect();
                // endd

                // 连接
                if (blnResult = Connect())
                {
                    // 执行
                    cmd.ExecuteNonQuery();
                }
            }
            catch (System.Exception ee)
            {
                blnResult = false;

                if (this.Debug)
                {
                    U_Pub_Zwd.ErrorMessage("数据库命令错误:" + ee.Message);
                }
            }
            finally
            {
                // 断开
                // del 2002-12-18
                //DisConnect();
                // endd
            }

            return(blnResult);
        }
Example #3
0
        // 数据库连接的维护 - 打开连接
        public bool Connect()
        {
            if (!Connected)
            {
                try
                {
                    Connection.ConnectionString = strConnection;
                    Connection.Open();
                    Connected = (Connection.State == System.Data.ConnectionState.Open);
                }
                catch (System.Exception ee)
                {
                    Connected = false;

                    if (this.Debug)
                    {
                        U_Pub_Zwd.ErrorMessage("数据库连接错误:" + ee.Message);
                    }
                }
            }

            return(Connected);
        }