• 数据库通用连接类


    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中字符串 s[ : 4]是什么意思?字符串切片
    python找不到模块的问题解决方法(有空钻研一下具体的原因)
    解决CUDA error: no kernel image is available for execution on the device 测试cuda是否可用
    执行 shell 报错 source:not found,一行注释解决
    【项目】项目137
    【项目】项目134
    【项目】项目135
    【项目】项目139
    【项目】项目142
    【项目】项目141
  • 原文地址:https://www.cnblogs.com/5tao/p/443727.html
Copyright © 2020-2023  润新知