天下無雙
阿龍 --质量是流程决定的。

using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.Web;

namespace SMB.Data
{
 public  class  Config:System.Web.UI.Page
 {
  public enum Provider
  {
   OLEDB,
   MSSQL,
  }
  private static Provider _Provider= Provider.MSSQL;
  //private static string  _ConnectionString = "server=.;uid=sa;pwd=ilovecw;Initial Catalog=test";
  private static string  _ConnectionString = "";

  /*Private _ConnectionString As String = "packet size=4096;integrated security=SSPI;data source=""(local)""" & _
  '    ";persist security info=False;initial catalog=EC"
  'Private _Provider As Provider = Provider.OLEDB
  'Private _ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\2004\SMB.Net\SMBSoftware\Dophin\SMB.mdb;" & _
  '    "Mode=Share Deny None;" & _
  '    "Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";" & _
  '    "Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;" & _
  '    "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;" & _
  '    "Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;" & _
  '    "Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;" & _
  '    "Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"
  */
  public static string ConnetionString
  {
   get
   {
    if(_ConnectionString=="")
    {
     DataSet ds=new DataSet();
     //string path=Request.ApplicationPath + @"/_System/DB.xml";
     //ds.ReadXml(HttpContext.Current.Server.MapPath(path));
     ds.ReadXml(HttpContext.Current.Server.MapPath(@"~/_System/DB.xml"));
     string strDBName=ds.Tables[0].Rows[0]["DataBaseName"].ToString();
     string strServer=ds.Tables[0].Rows[0]["Server"].ToString();
     string strUserID=ds.Tables[0].Rows[0]["UserID"].ToString();
     //ds.WriteXml(HttpContext.Current.Server.MapPath(@"_System/DB.xml"));

     _ConnectionString = "server=" + strServer + ";uid=" + strUserID + ";pwd=ilovecw;Initial Catalog=" + strDBName;
    }
    return _ConnectionString;
   }
   set{_ConnectionString = value;}
  }


  public static Provider DataProvider
  {
   get{return(_Provider);}
   set{_Provider = value;}

  }

 
  public static string MakeConnnectionString(string Server, string DataBaseName, string UserName, string Password)
  {
   string s;
   s = "server=" + Server + ";database=" + DataBaseName + ";uid=" + UserName + ";pwd=" + Password;
   return s;
  }

  public static string MakeConnnectionString(string DataBaseName,string UserName,string Password)
  {
   return (MakeConnnectionString("(local)", DataBaseName, UserName, Password));
  }
  public static string MakeConnnectionString(string UserName,string Password)
  {
   return (MakeConnnectionString("(local)", "EC", UserName, Password));
  }


 }
}

posted on 2007-07-21 17:25  阿龍  阅读(168)  评论(0编辑  收藏  举报