예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool   IsError      = false;
            string ErrorMessage = "";

            //MyUniDbConnection = new UniDbConnection(SQLServer.stAccess, "Database=TestuniDb2.mdb");
//            MyUniDbConnection = new UniDbConnection(SQLServer.stAccess, "", "G:\\DCDC\\Visual Studio Projects\\Db Stuff\\UniDb2\\Projects\\UniDb2\\bin\\Debug\\TestUniDb2.mdb", "", "", "");
//            MyUniDbConnection = new UniDbConnection(SQLServer.stText, "", "G:\\DCDC\\Visual Studio Projects\\Db Stuff\\UniDb2\\Projects\\UniDb2\\bin\\Debug", "", "", "");
            MyUniDbConnection = new UniDbConnection(SQLServer.stText, "", "G:\\DCDC\\Visual Studio Projects\\Db Stuff\\UniDb2\\Source", "", "", "");
            //            MyUniDbConnection = new UniDbConnection(SQLServer.stText, "", "I:\\Visual Studio Projects\\Db Stuff\\UniDb2\\Projects\\UniDb2\\bin\\Debug", "", "", "");
            MyUniDbConnection.Open();
//            DataTable DT = Tools.LoadTable(MyUniDbConnection, "TestTable", ref IsError, ref ErrorMessage);
            DataTable DT = Tools.LoadTable(MyUniDbConnection, "TxtDbTestFile1.cdf.txt", ref IsError, ref ErrorMessage);

            listBox1.Items.Clear();
            foreach (DataRow DR in DT.Rows)
            {
                string line = "";
                foreach (DataColumn DC in DT.Columns)
                {
                    string colval = DR[DC].ToString();
                    line += colval + " ";
                }
                listBox1.Items.Add(line);
            }
            MyUniDbConnection.Close();
        }
예제 #2
0
        public void CheckConnectionTest()
        {
            ProviderSetting.CurrentDBProvider = DbProviderType.OracleOdpNetManaged;
            UniDbConnection connect = new UniDbConnection("knvtest", "3");

            connect.Open();
            Assert.AreEqual(connect.State, ConnectionState.Open);

            UniDbCommand cmd = new UniDbCommand("select * from apstaff.emp where emp_birth_date=:p_date and per_num=:p_per_num and perco_sync_id=:p_perco_sync_id  order by per_num", connect);

            cmd.Parameters.Add("p_per_num", UniDbType.String, "14534");
            cmd.Parameters.Add("p_date", UniDbType.DateTime, new DateTime(1989, 7, 8));
            cmd.Parameters.Add("p_perco_sync_id", UniDbType.Decimal, 9479);
            UniDbDataReader dr = cmd.ExecuteReader();
            List <string>   ls = new List <string>();

            while (dr.Read())
            {
                ls.Add(dr["PER_NUM"].ToString());
            }
            Assert.AreEqual(ls.Count, 1);
            Assert.AreEqual(ls[ls.Count - 1], "14534");
            connect.Close();
            connect.Dispose();
        }
예제 #3
0
        public void CheckUniAdapterTest()
        {
            ProviderSetting.CurrentDBProvider = DbProviderType.OracleOdpNetManaged;
            UniDbConnection connect = new UniDbConnection("knvtest", "3");

            connect.Open();
            Assert.AreEqual(connect.State, ConnectionState.Open);

            UniDbAdapter a = new UniDbAdapter("select * from test_apstaff.temp_rep where per_num=:p_per_num", connect);

            a.TableMappings.Add("Table", "temp_rep");
            a.SelectCommand.Parameters.Add("p_per_num", UniDbType.String, "14534");
            DataSet ds = new DataSet();

            a.Fill(ds);
            a.Dispose();

            UniDbAdapter a1 = new UniDbAdapter("declare begin open :c for select * from test_apstaff.temp_rep where per_num=:p_per_num; end;", connect);

            a1.TableMappings.Add("Table", "temp_rep1");
            a1.SelectCommand.Parameters.Add("p_per_num", UniDbType.String, "14534");
            a1.SelectCommand.Parameters.Add("c", UniDbType.RefCursor);

            a1.Fill(ds);

            Assert.AreEqual(ds.Tables["temp_rep1"].Rows.Count, 2);

            UniDbAdapter a2 = new UniDbAdapter();
            UniDbCommand cm = new UniDbCommand("declare begin open :c for select * from test_apstaff.temp_rep where per_num=:p_per_num; end;", connect);

            a2.SelectCommand = cm;
            a2.TableMappings.Add("Table", "temp_rep2");
            a2.SelectCommand.Parameters.Add("p_per_num", UniDbType.String);
            a2.SelectCommand.Parameters.Add("c", UniDbType.RefCursor);
            a2.SelectCommand.SetParameters(new TestFilter());

            DataTable t = new DataTable();

            a2.Fill(ds);
            Assert.AreEqual(ds.Tables["temp_rep2"].Rows.Count, 2);
            Assert.IsTrue(ds.Tables["temp_rep2"].Rows.Cast <DataRow>().All(r => r["PER_NUM"].ToString() == "12714"));

            a2.SelectCommand.Parameters["p_per_num"].Value = "13772";
            a2.Fill(t);
            Assert.AreEqual(t.Rows.Count, 2);
            Assert.IsTrue(t.Rows.Cast <DataRow>().All(r => r["PER_NUM"].ToString() == "13772"));



            connect.Close();
            connect.Dispose();
        }