• 大小: 90KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-07
  • 语言: 其他
  • 标签:

资源简介

动态从数据库中绑定TreeView节点,很实用。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data;
using System.Configuration;

namespace DBHelper
{
    public class DBAccess
    {
        static public string connStr = ConfigurationManager.ConnectionStrings[“DBConnectionString“].ConnectionString;
        /// 
        /// 执行无参数无返回SQL查询,返回影响的记录数
        /// 

        /// SQL语句
        /// 影响的记录数
        public static int ExecuteNonQuery(string SQLString)
        {
            using (OleDbConnection conn = new OleDbConnection(connStr))
            {
                using (OleDbCommand cmd = new OleDbCommand(SQLString conn))
                {
                    try
                    {
                        if (conn.State.Equals(ConnectionState.Closed))
                            conn.Open();
                        int rows = cmd.ExecuteNonQuery();
                        return rows;
                    }
                    catch (OleDbException err)
                    {
                        throw new Exception(err.Message);
                    }
                    finally
                    {
                        cmd.Dispose();
                        conn.Close();
                    }
                }
            }
        }

        /// 
        /// 执行有参数无返回查询,返回影响的记录数
        /// 

        /// SQL
        /// 参数
        /// 影响的记录数
        public static int ExecuteNonQuery(string SQLString OleDbParameter[] prams)
        {
            using (OleDbConnection conn = new OleDbConnection(connStr))
            {
                using (OleDbCommand cmd = new OleDbCommand(SQLString conn))
                {
                    try
                    {
                        foreach (OleDbParameter item in prams)//添加参数
                        {
                            cmd.Parameters.Add(item);
                        }
                        if (conn.State.Equals(ConnectionState.Closed))
                            conn.Open();
                        int rows = cmd.ExecuteNonQuery();
                        return rows;
                    }
                    catch (OleDbException err)
                    {
                        throw new Exception(err.Message);
                    }
                    finally
                    {
                        cmd.Parameters.Clear();
                        cmd.Dispose();
                        conn.Close();
                    }
                }
            }
        }

        /// 
        /// 执行有参数有返回查询语句,返回SqlDataReader
        /// 

        /// 查询语句
        /// 参数
        /// SqlDataReader
        public static Ole

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1560  2009-08-01 01:05  动态从数据库中绑定TreeView节点\51bcw下载必读.txt

     文件       1560  2009-08-01 01:05  动态从数据库中绑定TreeView节点\DBHelper\51bcw下载必读.txt

     文件      20480  2009-07-19 12:20  动态从数据库中绑定TreeView节点\DBHelper\bin\Debug\DBHelper.dll

     文件      22016  2009-07-19 12:20  动态从数据库中绑定TreeView节点\DBHelper\bin\Debug\DBHelper.pdb

     文件       7848  2009-07-19 12:20  动态从数据库中绑定TreeView节点\DBHelper\DBAccess.cs

     文件       2005  2009-07-18 21:28  动态从数据库中绑定TreeView节点\DBHelper\DBHelper.csproj

     文件       1324  2010-04-28 10:56  动态从数据库中绑定TreeView节点\DBHelper\obj\DBHelper.csproj.FileListAbsolute.txt

     文件      20480  2009-07-19 12:20  动态从数据库中绑定TreeView节点\DBHelper\obj\Debug\DBHelper.dll

     文件      22016  2009-07-19 12:20  动态从数据库中绑定TreeView节点\DBHelper\obj\Debug\DBHelper.pdb

     文件      16384  2009-07-19 11:04  动态从数据库中绑定TreeView节点\DBHelper\obj\Debug\Refactor\DBHelper.dll

     文件       1311  2009-07-18 21:27  动态从数据库中绑定TreeView节点\DBHelper\Properties\AssemblyInfo.cs

     文件       1560  2009-08-01 01:05  动态从数据库中绑定TreeView节点\TreeViewDemo\51bcw下载必读.txt

     文件        247  2009-07-18 21:39  动态从数据库中绑定TreeView节点\TreeViewDemo\App.config

     文件     221184  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\bin\Debug\Database\TreeNodeCom.mdb

     文件      20480  2009-07-19 12:20  动态从数据库中绑定TreeView节点\TreeViewDemo\bin\Debug\DBHelper.dll

     文件      22016  2009-07-19 12:20  动态从数据库中绑定TreeView节点\TreeViewDemo\bin\Debug\DBHelper.pdb

     文件      28672  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\bin\Debug\TreeViewDemo.exe

     文件        247  2009-07-18 21:39  动态从数据库中绑定TreeView节点\TreeViewDemo\bin\Debug\TreeViewDemo.exe.config

     文件      32256  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\bin\Debug\TreeViewDemo.pdb

     文件       5632  2005-11-11 22:25  动态从数据库中绑定TreeView节点\TreeViewDemo\bin\Debug\TreeViewDemo.vshost.exe

     文件        247  2009-07-18 21:39  动态从数据库中绑定TreeView节点\TreeViewDemo\bin\Debug\TreeViewDemo.vshost.exe.config

     文件       9703  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\FrmTreeView.cs

     文件      16251  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\FrmTreeView.Designer.cs

     文件       6408  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\FrmTreeView.resx

     文件      10535  2010-04-28 10:56  动态从数据库中绑定TreeView节点\TreeViewDemo\obj\Debug\ResolveAssemblyReference.cache

     文件        848  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\obj\Debug\TreeViewDemo.csproj.GenerateResource.Cache

     文件      28672  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\obj\Debug\TreeViewDemo.exe

     文件        180  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\obj\Debug\TreeViewDemo.FrmTreeView.resources

     文件      32256  2009-07-19 12:37  动态从数据库中绑定TreeView节点\TreeViewDemo\obj\Debug\TreeViewDemo.pdb

     文件        180  2009-07-19 12:20  动态从数据库中绑定TreeView节点\TreeViewDemo\obj\Debug\TreeViewDemo.Properties.Resources.resources

............此处省略32个文件信息

评论

共有 条评论

相关资源