示例#1
0
        public void TableUpdate(TestCaseResult result)
        {
            DropTable();
            CreateTable();
            InsertRow(1);
            InsertRow(2);

            DataSet                dataset = new DataSet();
            VirtuosoDataAdapter    adapter = null;
            VirtuosoCommandBuilder builder = null;

            try
            {
                adapter = new VirtuosoDataAdapter();
                adapter.SelectCommand = new VirtuosoCommand("select * from foo", connection);
                adapter.Fill(dataset, "table");

                builder             = new VirtuosoCommandBuilder();
                builder.DataAdapter = adapter;

                DataTable table = dataset.Tables["table"];
                if (table.Rows.Count > 0)
                {
                    DataRow row = table.Rows[0];
                    row.Delete();
                }
                //if (table.Rows.Count > 1)
                //{
                //	DataRow row = table.Rows[1];
                //	row["j"] = 555;
                //	row["s"] = "bbb";
                //}
                DataRow newrow = table.NewRow();
                newrow["i"] = 3;
                newrow["n"] = 333;
                table.Rows.Add(newrow);

                adapter.Update(dataset, "Table");
            }
            finally
            {
                if (builder != null)
                {
                    builder.Dispose();
                    builder = null;
                }
                if (adapter != null)
                {
                    adapter.Dispose();
                    adapter = null;
                }
            }
        }
示例#2
0
        public void DeriveParamters(TestCaseResult result)
        {
            DropProcedure();
            ExecuteNonQuery(
                "create function BAR (in X integer, out Y integer, inout Z integer, in V varchar(20), in W nvarchar(20), in D numeric(20, 5)) returns real\n" +
                "{\n" +
                "  return 0.0;\n" +
                "}\n"
                );

            VirtuosoCommand command = connection.CreateCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "BAR";

            try
            {
                VirtuosoCommandBuilder.DeriveParameters(command);
                result.FailIfNotEqual("Parameter Count", 7, command.Parameters.Count);
                CheckParameter(result, command.Parameters[0],
                               "ReturnValue", ParameterDirection.ReturnValue, VirtDbType.Real, DbType.Single,
                               4, 0, 0);          // FIXME: The precision should be 7.
                CheckParameter(result, command.Parameters[1],
                               "X", ParameterDirection.Input, VirtDbType.Integer, DbType.Int32,
                               4, 10, 0);
                CheckParameter(result, command.Parameters[2],
                               "Y", ParameterDirection.Output, VirtDbType.Integer, DbType.Int32,
                               4, 10, 0);
                CheckParameter(result, command.Parameters[3],
                               "Z", ParameterDirection.InputOutput, VirtDbType.Integer, DbType.Int32,
                               4, 10, 0);
                CheckParameter(result, command.Parameters[4],
                               "V", ParameterDirection.Input, VirtDbType.VarChar, DbType.AnsiString,
                               20, 0, 0);
                CheckParameter(result, command.Parameters[5],
                               "W", ParameterDirection.Input, VirtDbType.NVarChar, DbType.String,
                               20, 0, 0);
                CheckParameter(result, command.Parameters[6],
                               "D", ParameterDirection.Input, VirtDbType.Decimal, DbType.Decimal,
                               19, 20, 5);
            }
            finally
            {
                command.Dispose();
            }
        }
示例#3
0
        public void GetMethods(TestCaseResult result)
        {
            DropTable();
            CreateTable();

            DataSet                dataset = new DataSet();
            VirtuosoDataAdapter    adapter = null;
            VirtuosoCommandBuilder builder = null;

            try
            {
                adapter = new VirtuosoDataAdapter();
                adapter.SelectCommand = new VirtuosoCommand("select * from foo", connection);
                adapter.Fill(dataset, "table");

                builder             = new VirtuosoCommandBuilder();
                builder.DataAdapter = adapter;

                VirtuosoCommand delete = builder.GetDeleteCommand();
                VirtuosoCommand insert = builder.GetInsertCommand();
                VirtuosoCommand update = builder.GetUpdateCommand();

                // dummy thing to evade the delete,insert,update not used warnings
                if (delete != null || insert != null || update != null)
                {
                    adapter = null;
                }
            }
            finally
            {
                if (builder != null)
                {
                    builder.Dispose();
                    builder = null;
                }
                if (adapter != null)
                {
                    adapter.Dispose();
                    adapter = null;
                }
            }
        }
		public void TableUpdate (TestCaseResult result)
		{
			DropTable ();
			CreateTable ();
			InsertRow (1);
			InsertRow (2);

			DataSet dataset = new DataSet ();
			VirtuosoDataAdapter adapter = null;
			VirtuosoCommandBuilder builder = null;
			try
			{
				adapter = new VirtuosoDataAdapter ();
				adapter.SelectCommand = new VirtuosoCommand ("select * from foo", connection);
				adapter.Fill (dataset, "table");

				builder = new VirtuosoCommandBuilder ();
				builder.DataAdapter = adapter;

				DataTable table = dataset.Tables["table"];
				if (table.Rows.Count > 0)
				{
					DataRow row = table.Rows[0];
					row.Delete ();
				}
				//if (table.Rows.Count > 1)
				//{
				//	DataRow row = table.Rows[1];
				//	row["j"] = 555;
				//	row["s"] = "bbb";
				//}
				DataRow newrow = table.NewRow ();
				newrow["i"] = 3;
				newrow["n"] = 333;
				table.Rows.Add (newrow);

				adapter.Update (dataset, "Table");
			}
			finally
			{
				if (builder != null)
				{
					builder.Dispose ();
					builder = null;
				}
				if (adapter != null)
				{
					adapter.Dispose ();
					adapter = null;
				}
			}
		}
		public void GetMethods (TestCaseResult result)
		{
			DropTable ();
			CreateTable ();

			DataSet dataset = new DataSet ();
			VirtuosoDataAdapter adapter = null;
			VirtuosoCommandBuilder builder = null;
			try
			{
				adapter = new VirtuosoDataAdapter ();
				adapter.SelectCommand = new VirtuosoCommand ("select * from foo", connection);
				adapter.Fill (dataset, "table");

				builder = new VirtuosoCommandBuilder ();
				builder.DataAdapter = adapter;

				VirtuosoCommand delete = builder.GetDeleteCommand ();
				VirtuosoCommand insert = builder.GetInsertCommand ();
				VirtuosoCommand update = builder.GetUpdateCommand ();

				// dummy thing to evade the delete,insert,update not used warnings
				if (delete != null || insert != null || update != null)
				  adapter = null;
			}
			finally
			{
				if (builder != null)
				{
					builder.Dispose ();
					builder = null;
				}
				if (adapter != null)
				{
					adapter.Dispose ();
					adapter = null;
				}
			}
		}