public VirtuosoConnection Connect(string connectionString) { VirtuosoConnection connection = new VirtuosoConnection(connectionString); connection.Open(); return(connection); }
public static int add_data (int nrows) { Object port = AppDomain.CurrentDomain.GetData("OpenLink.Virtuoso.InProcessPort"); if (port == null) throw new Exception ("not running as a hosted module"); VirtuosoConnection c = new VirtuosoConnection ("HOST=:in-process:" + port.ToString() + ";UID=dummy;PWD=dummy"); int i; c.Open(); new VirtuosoCommand ("exec_result_names (vector ('x'))", c).ExecuteNonQuery (); VirtuosoCommand cmd = new VirtuosoCommand ("result (?)", c); cmd.Parameters.Add (":1", SqlDbType.Int); for (i = 0; i < nrows; i++) { cmd.Parameters[":1"].Value = i; cmd.ExecuteNonQuery (); } cmd = null; c.Close(); return 0; }
public void CheckTable(VirtuosoConnection connection, TestCaseResult result) { VirtuosoCommand select = connection.CreateCommand(); select.CommandText = "select * from foo"; VirtuosoDataAdapter adapter = new VirtuosoDataAdapter(); adapter.SelectCommand = (VirtuosoCommand)select; DataSet dataset = new DataSet(); adapter.Fill(dataset); DataTable table = dataset.Tables["Table"]; result.FailIfNotEqual(checkTable.Rows.Count, table.Rows.Count); result.FailIfNotEqual(checkTable.Columns.Count, table.Columns.Count); for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; DataRow checkRow = checkTable.Rows[i]; for (int j = 0; j < table.Columns.Count; j++) { string name = table.Columns[j].ColumnName; result.FailIfNotEqual(checkRow[name], row[name]); } } }
public static int add_data(int nrows) { Object port = AppDomain.CurrentDomain.GetData("OpenLink.Virtuoso.InProcessPort"); if (port == null) { throw new Exception("not running as a hosted module"); } VirtuosoConnection c = new VirtuosoConnection("HOST=:in-process:" + port.ToString() + ";UID=dummy;PWD=dummy"); int i; c.Open(); new VirtuosoCommand("exec_result_names (vector ('x'))", c).ExecuteNonQuery(); VirtuosoCommand cmd = new VirtuosoCommand("result (?)", c); cmd.Parameters.Add(":1", SqlDbType.Int); for (i = 0; i < nrows; i++) { cmd.Parameters[":1"].Value = i; cmd.ExecuteNonQuery(); } cmd = null; c.Close(); return(0); }
protected override void TearDown() { DropTable(); connection.Close(); connection = null; }
public void Rollback(TestCaseResult result) { CheckDtcEnabled(result); worker.CheckTable(connection, result); XAction x = new XAction(); VirtuosoConnection xconn = null; try { string host = TestSettings.GetString("HOST", "localhost"); string connectionString = "HOST=" + host + ";UID=dba;PWD=dba;Pooling=True;"; xconn = x.Connect(connectionString); x.DoWork(xconn, worker); worker.CheckTable(xconn, result); x.Abort(); worker.DeleteRow(3); worker.DeleteRow(4); worker.CheckTable(connection, result); } finally { if (xconn != null) { xconn.Close(); } } }
protected override void SetUp() { string host = TestSettings.GetString("HOST"); string connectionString = "HOST=" + host + ";UID=dba;PWD=dba;"; connection = new VirtuosoConnection(connectionString); connection.Open(); }
public VirtuosoCommand(string cmdText, VirtuosoConnection connection, VirtuosoTransaction transaction) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoCommand.ctor()"); this.commandText = cmdText; this.connection = connection; this.transaction = transaction; this.parameters = new VirtuosoParameterCollection(this); }
// deprecated internal static void HandleWarnings( CLI.HandleType handleType, IntPtr handle, VirtuosoConnection connection) { VirtuosoInfoMessageEventArgs args = new VirtuosoInfoMessageEventArgs(OdbcErrors.CreateErrors(handleType, handle)); connection.OnInfoMessage(args); }
private VirtuosoCommand CollectInfo() { if (adapter == null) { throw new InvalidOperationException("The DataAdapter property is not set."); } VirtuosoCommand selectCommand = (VirtuosoCommand)adapter.SelectCommand; if (selectCommand == null) { throw new InvalidOperationException("The SelectCommand property is not set."); } VirtuosoConnection connection = (VirtuosoConnection)selectCommand.Connection; if (connection == null) { throw new InvalidOperationException("The Connection property is not set."); } if (columns != null) { return(selectCommand); } bool close = false; if (connection.State == ConnectionState.Closed) { connection.Open(); close = true; } VirtuosoDataReader reader = null; try { reader = (VirtuosoDataReader)selectCommand.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly); tableName = GetTableName(reader.Columns); columns = reader.Columns; } finally { if (reader != null) { reader.Close(); } if (close) { connection.Close(); } } return(selectCommand); }
protected override void SetUp() { string host = TestSettings.GetString("HOST", "localhost"); string connectionString = "HOST=" + host + ";UID=dba;PWD=dba;"; connection = new VirtuosoConnection(connectionString); connection.Open(); worker = new Worker(); worker.DropTable(connection); worker.CreateTable(connection); }
/// <summary> /// Creates a new connection to the Virtuoso storage. /// </summary> /// <param name="hostname">The host of the storage service.</param> /// <param name="port">The service port on the storage service host.</param> /// <param name="username">Username used to connect to storage.</param> /// <param name="password">Password needed to connect to storage.</param> public VirtuosoStore(string hostname, int port, string username, string password) { Hostname = hostname; Port = port.ToString(); Username = username; Password = password; Connection = new VirtuosoConnection(); Connection.ConnectionString = CreateConnectionString(); Connection.Open(); }
public BpelVarsAdaptor () { Object port = AppDomain.CurrentDomain.GetData("OpenLink.Virtuoso.InProcessPort"); if (port == null) throw new Exception ("not running as a hosted module"); // Console.WriteLine ("HOST=localhost:" + port.ToString()); c = new VirtuosoConnection ("HOST=:in-process:" + port.ToString() + ";UID=dummy;PWD=dummy"); }
internal IInnerConnection GetConnection(ConnectionOptions options, VirtuosoConnection connection) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "ConnectionPool.GetConnection ()"); IInnerConnection innerConnection = null; if (options.Enlist && ContextUtil.IsInTransaction) { innerConnection = (IInnerConnection)dtcPool.GetResource(); if (innerConnection != null) { innerConnection.OuterConnectionWeakRef = new WeakReference(connection); return(innerConnection); } } lock (this) { if (pool == null) { pool = new IInnerConnection[maxSize]; for (int i = 0; i < minSize; i++) { innerConnection = connection.CreateInnerConnection(options, false); innerConnection.TimeStamp = DateTime.Now; PutConnection(innerConnection); } } if (size > 0) { innerConnection = pool[--size]; } } if (innerConnection == null) { innerConnection = connection.CreateInnerConnection(options, true); innerConnection.TimeStamp = DateTime.Now; } else { innerConnection.OuterConnectionWeakRef = new WeakReference(connection); #if MTS if (options.Enlist && ContextUtil.IsInTransaction) { connection.EnlistInnerConnection(innerConnection); } #endif } return(innerConnection); }
public BpelVarsAdaptor() { Object port = AppDomain.CurrentDomain.GetData("OpenLink.Virtuoso.InProcessPort"); if (port == null) { throw new Exception("not running as a hosted module"); } // Console.WriteLine ("HOST=localhost:" + port.ToString()); c = new VirtuosoConnection("HOST=:in-process:" + port.ToString() + ";UID=dummy;PWD=dummy"); }
protected override void SetUp() { string host = TestSettings.GetString("HOST"); string connectionString = "HOST=" + host + ";UID=dba;PWD=dba;DATABASE=db;"; connection = new VirtuosoConnection(connectionString); connection.Open(); CreateTable(); for (int i = 0; i < NRows; i++) { InsertRow(i); } }
// deprecated internal static void HandleResult( CLI.ReturnCode returnCode, CLI.HandleType handleType, IntPtr handle, VirtuosoConnection connection) { if (returnCode == CLI.ReturnCode.SQL_SUCCESS_WITH_INFO) { HandleWarnings(handleType, handle, connection); } else if (returnCode != CLI.ReturnCode.SQL_SUCCESS) { HandleErrors(returnCode, handleType, handle); } }
public void CreateTable(VirtuosoConnection connection) { VirtuosoCommand create = connection.CreateCommand(); create.CommandText = "create table foo (id int primary key, txt varchar(100))"; create.ExecuteNonQuery(); create.Dispose(); checkTable = new DataTable(); checkTable.Columns.Add("id", typeof(int)); checkTable.Columns.Add("txt", typeof(string)); InsertRow(connection, 1); InsertRow(connection, 2); }
public void OdbcConnectionWithoutPooling(TestCaseResult result) { string host = TestSettings.GetString("HOST"); string connectionString = "HOST=" + host + ";UID=dba;PWD=dba;Pooling=False;"; VirtuosoConnection conn = new VirtuosoConnection(connectionString); try { conn.Open(); conn.Close(); } finally { conn.Dispose(); } }
public void DropTable(VirtuosoConnection connection) { VirtuosoCommand drop = connection.CreateCommand(); drop.CommandText = "drop table foo"; try { drop.ExecuteNonQuery(); } catch (Exception) { } finally { drop.Dispose(); } }
public VirtuosoDotNetDSNForm(String name, String connect_string) : this(name) { VirtuosoConnection c = new VirtuosoConnection(connect_string); try { string [] hp = c.GetConnectionOption("HOST").Split(":".ToCharArray()); string host, port; if (hp.Length > 1) { host = hp[0]; port = hp[1]; } else { host = "localhost"; port = "1111"; try { if (int.Parse(hp[0]) > 0) { host = "localhost"; port = hp[0]; } } catch { port = "1111"; host = hp[0]; } } this.tbHostName.Text = hp.Length > 1 ? hp[0] : "localhost"; this.tbPort.Text = hp.Length > 1 ? hp[1] : hp[0]; } catch { } try { this.tbUserID.Text = c.GetConnectionOption("UID"); } catch {} try { this.tbPwd.Text = c.GetConnectionOption("PWD"); } catch {} this.tbSourceName.Enabled = false; this.Text = "Edit Data Source"; }
private void Dispose(bool disposing) #endif { try { if (disposing) { Close(); } connection = null; } catch (Exception e) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtousoDataReader.Dispose caught exception: " + e.Message); } }
public void InsertRow(VirtuosoConnection connection, int i) { string s = new string (new char[3] { (char)('a' + i), (char)('b' + i), (char)('c' + i) }); VirtuosoCommand insert = connection.CreateCommand(); insert.CommandText = "insert into foo values (" + i + ", '" + s + "')"; insert.ExecuteNonQuery(); insert.Dispose(); DataRow row = checkTable.NewRow(); row["id"] = i; row["txt"] = s; checkTable.Rows.Add(row); }
private static void TestPooling(string connString) { const int n = 1000 /*, m = 100*/; string connStringPool = connString + ";Pooling=true"; string connStringNoPool = connString + ";Pooling=false"; VirtuosoConnection first, conn = null; DateTime start; int i; first = new VirtuosoConnection(connStringNoPool); start = DateTime.Now; System.Console.WriteLine("before Open(): {0}.{1:000}", DateTime.Now.Second, DateTime.Now.Millisecond); first.Open(); System.Console.WriteLine("after Open(): {0}.{1:000}", DateTime.Now.Second, DateTime.Now.Millisecond); System.Console.WriteLine("open first connection {0}", DateTime.Now - start); System.Console.WriteLine("With pooling enabled"); conn = new VirtuosoConnection(connStringPool); start = DateTime.Now; for (i = 0; i < n; i++) { //if ((i % m) == 0) // System.Console.WriteLine ("i={0}", i); conn.Open(); conn.Close(); } System.Console.WriteLine("{0} connections: {1}", n, DateTime.Now - start); System.Console.WriteLine("With pooling disabled"); conn = new VirtuosoConnection(connStringNoPool); start = DateTime.Now; for (i = 0; i < n; i++) { //if ((i % m) == 0) // System.Console.WriteLine ("i={0}", i); conn.Open(); conn.Close(); } System.Console.WriteLine("{0} connections: {1}", n, DateTime.Now - start); start = DateTime.Now; first.Close(); System.Console.WriteLine("close first connection {0}", DateTime.Now - start); }
private static void TestPooling (string connString) { const int n = 1000/*, m = 100*/; string connStringPool = connString + ";Pooling=true"; string connStringNoPool = connString + ";Pooling=false"; VirtuosoConnection first, conn = null; DateTime start; int i; first = new VirtuosoConnection (connStringNoPool); start = DateTime.Now; System.Console.WriteLine ("before Open(): {0}.{1:000}", DateTime.Now.Second, DateTime.Now.Millisecond); first.Open (); System.Console.WriteLine ("after Open(): {0}.{1:000}", DateTime.Now.Second, DateTime.Now.Millisecond); System.Console.WriteLine ("open first connection {0}", DateTime.Now - start); System.Console.WriteLine ("With pooling enabled"); conn = new VirtuosoConnection (connStringPool); start = DateTime.Now; for (i = 0; i < n; i++) { //if ((i % m) == 0) // System.Console.WriteLine ("i={0}", i); conn.Open (); conn.Close (); } System.Console.WriteLine ("{0} connections: {1}", n, DateTime.Now - start); System.Console.WriteLine ("With pooling disabled"); conn = new VirtuosoConnection (connStringNoPool); start = DateTime.Now; for (i = 0; i < n; i++) { //if ((i % m) == 0) // System.Console.WriteLine ("i={0}", i); conn.Open (); conn.Close (); } System.Console.WriteLine ("{0} connections: {1}", n, DateTime.Now - start); start = DateTime.Now; first.Close (); System.Console.WriteLine ("close first connection {0}", DateTime.Now - start); }
public void State(TestCaseResult result) { string host = TestSettings.GetString("HOST"); string connectionString = "HOST=" + host + ";UID=dba;PWD=dba;"; VirtuosoConnection conn = new VirtuosoConnection(connectionString); try { result.FailIfNotEqual(ConnectionState.Closed, conn.State); conn.Open(); result.FailIfNotEqual(ConnectionState.Open, conn.State); conn.Close(); result.FailIfNotEqual(ConnectionState.Closed, conn.State); } finally { conn.Dispose(); } }
public void PersistSecurityInfo(TestCaseResult result) { string host = TestSettings.GetString("HOST"); string connectionString = "HOST=" + host + ";UID=dba;PWD=dba;Persist Security Info=true;"; VirtuosoConnection conn = new VirtuosoConnection(connectionString); try { result.FailIfNotEqual(connectionString, conn.ConnectionString); conn.Open(); result.FailIfNotEqual(connectionString, conn.ConnectionString); conn.Close(); result.FailIfNotEqual(connectionString, conn.ConnectionString); } finally { conn.Dispose(); } }
public void Close() #endif { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoDataReader.Close()"); if (open) { if (command != null) { command.CloseDataReader(); command = null; } if (connection != null && (commandBehavior & CommandBehavior.CloseConnection) != 0) { connection.Close(); connection = null; } columns = null; open = false; } }
public void DisposeInvalid(TestCaseResult result) { VirtuosoConnection conn = null; try { string connectionString = "InvalidConnectionString"; conn = new VirtuosoConnection(connectionString); } catch (ArgumentException) { // suppress ArgumentException } finally { if (conn != null) { conn.Dispose(); } } }
protected override void Dispose(bool disposing) { try { if (disposing) { DisposeStatement(); } base.Dispose(disposing); if (connection != null && connection.innerConnection != null) { connection.innerConnection.RemoveCommand(this); } connection = null; transaction = null; } catch (Exception e) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoCommand.Dispose caught exception: " + e.Message); } }
/* * Because the user should not be able to directly create a * DataReader object, the constructors are * marked as internal. */ internal VirtuosoDataReader( VirtuosoConnection connection, IInnerCommand innerCommand, VirtuosoCommand command, CommandBehavior commandBehavior, bool schemaOnly) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoDataReader.ctor()"); Debug.Assert(connection != null); Debug.Assert(innerCommand != null); this.connection = connection; this.command = command; this.innerCommand = innerCommand; this.commandBehavior = commandBehavior; InitializeResultInfo(schemaOnly); if (schemaOnly) { over = true; last = true; } }
private void Dispose(bool disposing) #endif { if (disposing) { if (!ended) { try { Rollback(); } catch (Exception e) { // Dispose method should never throw an exception. // So just log any messages. Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoTransaction.Dispose caught exception: " + e.Message); } } } connection = null; #if ADONET2 base.Dispose(disposing); #endif }
/* * Now inherited from the System.ComponentModel.Component * ~VirtuosoConnection () { Dispose (false); } */ /* * Now inherited from the System.ComponentModel.Component * public void Dispose () { Dispose (true); GC.SuppressFinalize (this); } */ object ICloneable.Clone () { VirtuosoConnection conn = new VirtuosoConnection (); conn.options = this.options; return conn; }
public VirtuosoDataAdapter (string selectCommandText, VirtuosoConnection selectConnection) : this (new VirtuosoCommand (selectCommandText, selectConnection)) { }
// deprecated internal static void HandleResult ( CLI.ReturnCode returnCode, CLI.HandleType handleType, IntPtr handle, VirtuosoConnection connection) { if (returnCode == CLI.ReturnCode.SQL_SUCCESS_WITH_INFO) HandleWarnings (handleType, handle, connection); else if (returnCode != CLI.ReturnCode.SQL_SUCCESS) HandleErrors (returnCode, handleType, handle); }
public VirtuosoCommand(string cmdText, VirtuosoConnection connection) : this(cmdText, connection, null) { }
public VirtuosoCommand (string cmdText, VirtuosoConnection connection, VirtuosoTransaction transaction) { Debug.WriteLineIf (CLI.FnTrace.Enabled, "VirtuosoCommand.ctor()"); this.commandText = cmdText; this.connection = connection; this.transaction = transaction; this.parameters = new VirtuosoParameterCollection (this); }
private void Dispose (bool disposing) #endif { try { if (disposing) Close (); connection = null; } catch (Exception e) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtousoDataReader.Dispose caught exception: " + e.Message); } }
private void Dispose (bool disposing) #endif { if (disposing) { if (!ended) { try { Rollback (); } catch (Exception e) { // Dispose method should never throw an exception. // So just log any messages. Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoTransaction.Dispose caught exception: " + e.Message); } } } connection = null; #if ADONET2 base.Dispose(disposing); #endif }
/* * Because the user should not be able to directly create a * DataReader object, the constructors are * marked as internal. */ internal VirtuosoDataReader ( VirtuosoConnection connection, IInnerCommand innerCommand, VirtuosoCommand command, CommandBehavior commandBehavior, bool schemaOnly) { Debug.WriteLineIf (CLI.FnTrace.Enabled, "VirtuosoDataReader.ctor()"); Debug.Assert (connection != null); Debug.Assert (innerCommand != null); this.connection = connection; this.command = command; this.innerCommand = innerCommand; this.commandBehavior = commandBehavior; InitializeResultInfo (schemaOnly); if (schemaOnly) { over = true; last = true; } }
public void Close () #endif { Debug.WriteLineIf (CLI.FnTrace.Enabled, "VirtuosoDataReader.Close()"); if (open) { if (command != null) { command.CloseDataReader (); command = null; } if (connection != null && (commandBehavior & CommandBehavior.CloseConnection) != 0) { connection.Close (); connection = null; } columns = null; open = false; } }
internal IInnerConnection GetConnection (ConnectionOptions options, VirtuosoConnection connection) { Debug.WriteLineIf (CLI.FnTrace.Enabled, "ConnectionPool.GetConnection ()"); IInnerConnection innerConnection = null; if (options.Enlist && ContextUtil.IsInTransaction) { innerConnection = (IInnerConnection) dtcPool.GetResource (); if (innerConnection != null) { innerConnection.OuterConnectionWeakRef = new WeakReference (connection); return innerConnection; } } lock (this) { if (pool == null) { pool = new IInnerConnection[maxSize]; for (int i = 0; i < minSize; i++) { innerConnection = connection.CreateInnerConnection (options, false); innerConnection.TimeStamp = DateTime.Now; PutConnection (innerConnection); } } if (size > 0) innerConnection = pool[--size]; } if (innerConnection == null) { innerConnection = connection.CreateInnerConnection (options, true); innerConnection.TimeStamp = DateTime.Now; } else { innerConnection.OuterConnectionWeakRef = new WeakReference (connection); #if MTS if (options.Enlist && ContextUtil.IsInTransaction) connection.EnlistInnerConnection (innerConnection); #endif } return innerConnection; }
internal void SetParameters (VirtuosoConnection connection, IntPtr hstmt) { Debug.WriteLineIf (CLI.FnTrace.Enabled, "ParameterData.SetParameters()"); for (int i = 0; i < parameters.Count; i++) { VirtuosoParameter param = (VirtuosoParameter) parameters[i]; Debug.WriteLineIf (Switch.Enabled, " param: " + param.paramName); CLI.InOutType ioType; switch (param.Direction) { default: // case ParameterDirection.Input: ioType = CLI.InOutType.SQL_PARAM_INPUT; break; case ParameterDirection.InputOutput: ioType = CLI.InOutType.SQL_PARAM_INPUT_OUTPUT; break; case ParameterDirection.Output: case ParameterDirection.ReturnValue: ioType = CLI.InOutType.SQL_PARAM_OUTPUT; break; } Debug.WriteLineIf (Switch.Enabled, " direction: " + param.Direction); IntPtr paramBuffer = buffer.GetAddress (offset[i]); int bufferLength = length[i]; int lengthOffset = 4 * i; CLI.SqlType sqlType = (param.paramType != null ? param.paramType.sqlType : CLI.SqlType.SQL_UNKNOWN_TYPE); CLI.ReturnCode rc = (CLI.ReturnCode) CLI.SQLBindParameter ( hstmt, (ushort) (i + 1), (short) ioType, (short) param.bufferType.sqlCType, (short) sqlType, (IntPtr) param.Size, param.Scale, paramBuffer, (IntPtr) bufferLength, buffer.GetAddress (lengthOffset)); if (rc != CLI.ReturnCode.SQL_SUCCESS) Diagnostics.HandleResult (rc, CLI.HandleType.SQL_HANDLE_STMT, hstmt, connection); if (param.Direction == ParameterDirection.Input || param.Direction == ParameterDirection.InputOutput) { object value = param.bufferType.ConvertValue (param.Value); Debug.WriteLineIf (Switch.Enabled, " value: " + param.Value); int dataLength; if (value == null) dataLength = (int) CLI.LengthCode.SQL_NULL_DATA; else if (Convert.IsDBNull (value)) dataLength = (int) CLI.LengthCode.SQL_NULL_DATA; else dataLength = param.bufferType.ManagedToNative (value, paramBuffer, bufferLength); Marshal.WriteInt32 (buffer.Handle, lengthOffset, dataLength); } } }
// deprecated internal static void HandleWarnings ( CLI.HandleType handleType, IntPtr handle, VirtuosoConnection connection) { VirtuosoInfoMessageEventArgs args = new VirtuosoInfoMessageEventArgs (OdbcErrors.CreateErrors (handleType, handle)); connection.OnInfoMessage (args); }
// // Empties the connection pool associated with the specified connection. // ClearPool clears the connection pool that is associated with the // connection. If additional connections associated with the pool // are in use at the time of the call, they are marked appropriately // and are discarded (instead of being returned to the pool) when // Close is called on them. // public static void ClearPool(VirtuosoConnection connection) { if (connection == null) throw new ArgumentNullException("connection"); if (!connection.options.Pooling || connection.pool == null) throw new InvalidOperationException("This connection is not pooled."); ConnectionPool.ClearPool(connection.options.ConnectionString); }
public VirtuosoDotNetDSNForm(String name, String connect_string) : this(name) { VirtuosoConnection c = new VirtuosoConnection (connect_string); try { string [] hp = c.GetConnectionOption ("HOST").Split (":".ToCharArray ()); string host, port; if (hp.Length > 1) { host = hp[0]; port = hp[1]; } else { host = "localhost"; port = "1111"; try { if (int.Parse(hp[0]) > 0) { host = "localhost"; port = hp[0]; } } catch { port = "1111"; host = hp[0]; } } this.tbHostName.Text = hp.Length > 1 ? hp[0] : "localhost"; this.tbPort.Text = hp.Length > 1 ? hp[1] : hp[0]; } catch { } try { this.tbUserID.Text = c.GetConnectionOption ("UID"); } catch {} try { this.tbPwd.Text = c.GetConnectionOption ("PWD"); } catch {} this.tbSourceName.Enabled = false; this.Text = "Edit Data Source"; }
protected override void Dispose (bool disposing) { try { if (disposing) { DisposeStatement (); } base.Dispose (disposing); if (connection != null && connection.innerConnection != null) connection.innerConnection.RemoveCommand (this); connection = null; transaction = null; } catch (Exception e) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoCommand.Dispose caught exception: " + e.Message); } }
internal VirtuosoTransaction (VirtuosoConnection connection, System.Data.IsolationLevel isolation) { this.connection = connection; this.isolation = isolation; this.ended = false; }
public VirtuosoCommand (string cmdText, VirtuosoConnection connection) : this (cmdText, connection, null) { }
static void Main (string[] args) { try { VirtuosoConnection conn; if (args.Length > 0) { TestPooling (args[0]); if (args.Length > 1 && args[1] == "-e") return; conn = new VirtuosoConnection (args[0]); } else conn = new VirtuosoConnection (); conn.Open (); IDbCommand drop = conn.CreateCommand(); drop.CommandText = "drop table foo"; try { drop.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine("Got an Exception."); Console.WriteLine("{0}", e.Message); Console.WriteLine("StackTrace:"); Console.WriteLine("{0}", e.StackTrace); } finally { drop.Dispose(); } IDbCommand create = conn.CreateCommand(); create.CommandText = "create table foo (id int primary key, txt varchar(100))"; create.ExecuteNonQuery(); create.Dispose(); int rc; IDbCommand insert_1 = conn.CreateCommand(); insert_1.CommandText = "insert into foo foo values (1, 'lorem')"; rc = insert_1.ExecuteNonQuery(); insert_1.Dispose(); Console.WriteLine("rc: {0}", rc); IDbCommand insert_2 = conn.CreateCommand(); insert_2.CommandText = "insert into foo foo values (2, 'ipsum')"; rc = insert_2.ExecuteNonQuery(); insert_2.Dispose(); Console.WriteLine("rc: {0}", rc); IDbCommand select = conn.CreateCommand(); select.CommandText = "select * from foo"; IDataReader reader = select.ExecuteReader(); DataSet dataset = new DataSet(); DataTable schemaTable = reader.GetSchemaTable (); dataset.Tables.Add (schemaTable); VirtuosoDataAdapter adapter = new VirtuosoDataAdapter(); adapter.SelectCommand = (VirtuosoCommand)select; adapter.Fill(dataset); //reader.Dispose(); //select.Dispose(); //conn.Dispose(); Form[] forms = new Form[dataset.Tables.Count]; instance_count = 0; foreach (DataTable t in dataset.Tables) { forms[instance_count] = new Test (dataset, t.TableName); forms[instance_count].Closed += new EventHandler (Test_Closed); forms[instance_count].Show (); instance_count++; } Application.Run (); } catch (Exception e) { Console.WriteLine("Got an Exception."); Console.WriteLine("{0}", e.Message); Console.WriteLine("StackTrace:"); Console.WriteLine("{0}", e.StackTrace); } }