zoukankan      html  css  js  c++  java
  • 数据库通用连接类

    using System;
    using System.Data ;
    using System.Data.SqlClient ;
    using System.Data.SqlTypes ;
    using System.Windows.Forms ;
    using System.Collections;
    namespace Database
    {
     
    /// <summary>
     
    /// Database 的摘要说明。
     
    /// </summary>

     public class Database
     
    {
      
    /// <summary>
      
    /// 属性
      
    /// </summary>

    //  public DataSet dataSet
    //  {
    //   get
    //   {
    //    return m_DataSet;
    //   }
    //   
    //  }
      public Database()
      
    {
       
    //
       
    // TODO: 在此处添加构造函数逻辑
       
    //
       XmlRead ConStr=new XmlRead();
       
    if (ConStr.ReadAllConnectNode())
       
    {
        constr
    = ConStr.connstring ;
    //    try
    //    {
    //     
    //     Open();
    //    }
    //    catch(Exception Ex)
    //    {
    //     MessageBox.Show("数据库连接错误"+Ex.ToString () );
    //    
    //    }
        
       }

       
    else
       
    {
       constr
    ="-1";
       
    //throw new SqlErrorCollection();

       }

       

      }

    //  public bool Open()
    //  {
    //   
    //   mcn.ConnectionString = constr;
    //   try
    //   {
    //    mcn.Open();
    //    
    //   }
    //   catch( Exception)
    //   {
    //    return  false;
    //   }
    //   return true;
    //  }
      /// <summary>
      
    /// 默认获取DataSet
      
    /// </summary>
      
    /// <param name="pMyTableName"></param>
      
    /// <param name="tmpMyComputerName"></param>
      
    /// <returns></returns>

    //  public virtual int getData (string pMyTableName ,string tmpMyComputerName)
    //  {
    //   return -1;
    //
    //  }
      ExecuteNonQuery
      
    ExecuteReader

      
    private函数
      
    填充DataSet

     
    internal  string constr= null;//= "Uid =sa ;Pwd=sa ;Server = Drago;Database =Northwind";
     internal SqlConnection mcn = new SqlConnection();
     
    internal DataSet m_DataSet =new System.Data.DataSet() ;
     }

     
    }


  • 相关阅读:
    Python学习(四)数据结构 —— list tuple range
    Python学习(四)数据结构 —— bool
    Python学习(四)数据结构 —— int float
    Python学习(四)数据结构(概要)
    Python学习(三)流程控制
    Python学习(二)Python 简介
    Python学习(一)安装、环境配置及IDE推荐
    iOS崩溃日志 如何看
    python 读取excel表格内不同类型的数据
    python xlrd读取excel常用方法
  • 原文地址:https://www.cnblogs.com/5tao/p/443727.html
Copyright © 2011-2022 走看看