Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 2
0
        public DataTable ExecuteQuery(string queryString, ITransaction transaction = null)
        {
            DataTable result = new DataTable();

            VirtuosoDataAdapter adapter = null;
            VirtuosoCommand     command = null;

            try
            {
                command             = Connection.CreateCommand();
                command.CommandText = queryString;

                if (transaction != null && transaction is VirtuosoTransaction)
                {
                    command.Transaction = (transaction as VirtuosoTransaction).Transaction;
                }

                result.Columns.CollectionChanged += OnColumnsCollectionChanged;

                adapter = new VirtuosoDataAdapter(command);
                adapter.Fill(result);

                result.Columns.CollectionChanged -= OnColumnsCollectionChanged;
            }
            catch (InvalidOperationException ex)
            {
                string msg = string.Format("Error: Caught {0} exception.", ex.GetType());
                Debug.WriteLine(msg);
            } /* This seems to be different in 7.x version of Openlink.Virtuoso.dll
               * catch (VirtuosoException e)
               * {
               *
               * if (e.ErrorCode == 40001)
               *    throw new ResourceLockedException(e);
               * else
               *
               *    throw;
               * } */
            finally
            {
                if (adapter != null)
                {
                    adapter.Dispose();
                }

                if (command != null)
                {
                    command.Dispose();
                }
            }

            return(result);
        }
Ejemplo n.º 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;
				}
			}
		}