예제 #1
0
        public Database(string Databasetype, string Connection)
        {
            dbtype = Databasetype;
            switch (dbtype)
            {
            case "Mssql":
                //server={0};database={1};uid={2};pwd={3}
                cmd_mssql            = new SqlCommand();
                cmd_mssql.Connection = new SqlConnection(Connection);
                break;

            case "Access":
                //"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\db.mdb;Jet OLEDB:Database Password=zhwykj&1712"
                cmd_access            = new OleDbCommand();
                cmd_access.Connection = new OleDbConnection(Connection);
                break;

            case "Oracle":
                //"Host=127.0.0.1;Port=1521;User ID=scott;Password=tiger;Service Name=ORCL"
                cmd_oracle            = new DDTek.Oracle.OracleCommand();
                cmd_oracle.Connection = new DDTek.Oracle.OracleConnection(Connection);
                break;

            default:
                throw new Exception("无法识别的数据库类型!");
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: hy1314200/HyDM
        public Form1()
        {
            InitializeComponent();

            DataTable dtProviderFactorys = DbProviderFactories.GetFactoryClasses();

            DbConnectionStringBuilder dcsBuilder = new DbConnectionStringBuilder();
            dcsBuilder.Add("User ID", "hzzgis");
            dcsBuilder.Add("Password", "hzzgis");
            dcsBuilder.Add("Service Name", "sunz");
            dcsBuilder.Add("Host", "172.16.1.9");
            dcsBuilder.Add("Integrated Security", false);

            string licPath = Application.StartupPath + "\\DDTek.lic";
            if (!System.IO.File.Exists(licPath))
                licPath = CretateDDTekLic.CreateLic();
            dcsBuilder.Add("License Path", licPath);
            //若路径中存在空格,则会在路径名称前加上"\""
            string conStr = dcsBuilder.ConnectionString;
            conStr = conStr.Replace("\"", "");

            DDTek.Oracle.OracleConnection orclConnection = new DDTek.Oracle.OracleConnection(conStr);

            DDTek.Oracle.OracleCommand cmd = new DDTek.Oracle.OracleCommand();
            DDTek.Oracle.OracleDataAdapter adapter = new DDTek.Oracle.OracleDataAdapter();
            adapter.SelectCommand = cmd;
            DbDataAdapter dAdapter = adapter;
            DbCommand dbCommand = dAdapter.SelectCommand;

            orclConnection.Open();

            //Configuration config = new Configuration();

            //ISessionFactory pFactory = config.BuildSessionFactory();
            //ISession pSession= pFactory.OpenSession(orclConnection as IDbConnection);

            //DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OracleClient");
            //IDbConnection dbConn = factory.CreateConnection();
            //if (dbConn != null)
            //    MessageBox.Show("Connection Created");
            //Conn.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Server + ")(PORT=" + Port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + Service + ")));user id=" + User + ";password="******";pooling = true;Unicode=True";

            IDbConnection dbConn=new System.Data.OleDb.OleDbConnection();
            string Server = "sunzvm-lc", Port = "1521", Service = "sunz", User = "******", PWD = "hzzgis";
            //dbConn.ConnectionString = "Provider=OraOLEDB.Oracle.1;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Server + ")(PORT=" + Port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + Service + ")));user id=" + User + ";password="******";pooling = true;Unicode=True";
            dbConn.ConnectionString = "Provider=MSDAORA.1;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Server + ")(PORT=" + Port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + Service + ")));user id=" + User + ";password="******";pooling = true;Unicode=True";

            try
            {
                dbConn.Open();
            }
            catch(Exception exp)
            {
                MessageBox.Show(exp.ToString());
            }
        }
예제 #3
0
 internal HyOracleCommand(DDTek.Oracle.OracleCommand cmd)
 {
     this.m_Command = cmd;
     this.m_Connection = new HyOracleConnection(cmd.Connection);
 }
예제 #4
0
 internal HyOracleCommand(DDTek.Oracle.OracleCommand cmd, HyOracleConnection conn)
 {
     this.m_Command = cmd;
     this.m_Connection = conn;
 }
예제 #5
0
 internal HyOracleCommand(DDTek.Oracle.OracleCommand cmd, HyOracleConnection conn)
 {
     this.m_Command    = cmd;
     this.m_Connection = conn;
 }
예제 #6
0
파일: Form1.cs 프로젝트: zj8487/HyDM
        public Form1()
        {
            InitializeComponent();



            DataTable dtProviderFactorys = DbProviderFactories.GetFactoryClasses();



            DbConnectionStringBuilder dcsBuilder = new DbConnectionStringBuilder();

            dcsBuilder.Add("User ID", "hzzgis");
            dcsBuilder.Add("Password", "hzzgis");
            dcsBuilder.Add("Service Name", "sunz");
            dcsBuilder.Add("Host", "172.16.1.9");
            dcsBuilder.Add("Integrated Security", false);


            string licPath = Application.StartupPath + "\\DDTek.lic";

            if (!System.IO.File.Exists(licPath))
            {
                licPath = CretateDDTekLic.CreateLic();
            }
            dcsBuilder.Add("License Path", licPath);
            //若路径中存在空格,则会在路径名称前加上"\""
            string conStr = dcsBuilder.ConnectionString;

            conStr = conStr.Replace("\"", "");

            DDTek.Oracle.OracleConnection orclConnection = new DDTek.Oracle.OracleConnection(conStr);

            DDTek.Oracle.OracleCommand     cmd     = new DDTek.Oracle.OracleCommand();
            DDTek.Oracle.OracleDataAdapter adapter = new DDTek.Oracle.OracleDataAdapter();
            adapter.SelectCommand = cmd;
            DbDataAdapter dAdapter  = adapter;
            DbCommand     dbCommand = dAdapter.SelectCommand;

            orclConnection.Open();

            //Configuration config = new Configuration();

            //ISessionFactory pFactory = config.BuildSessionFactory();
            //ISession pSession= pFactory.OpenSession(orclConnection as IDbConnection);

            //DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OracleClient");
            //IDbConnection dbConn = factory.CreateConnection();
            //if (dbConn != null)
            //    MessageBox.Show("Connection Created");
            //Conn.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Server + ")(PORT=" + Port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + Service + ")));user id=" + User + ";password="******";pooling = true;Unicode=True";

            IDbConnection dbConn = new System.Data.OleDb.OleDbConnection();
            string        Server = "sunzvm-lc", Port = "1521", Service = "sunz", User = "******", PWD = "hzzgis";

            //dbConn.ConnectionString = "Provider=OraOLEDB.Oracle.1;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Server + ")(PORT=" + Port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + Service + ")));user id=" + User + ";password="******";pooling = true;Unicode=True";
            dbConn.ConnectionString = "Provider=MSDAORA.1;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Server + ")(PORT=" + Port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + Service + ")));user id=" + User + ";password="******";pooling = true;Unicode=True";

            try
            {
                dbConn.Open();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.ToString());
            }
        }
예제 #7
0
 internal HyOracleCommand(DDTek.Oracle.OracleCommand cmd)
 {
     this.m_Command    = cmd;
     this.m_Connection = new HyOracleConnection(cmd.Connection);
 }