bool NextResult() { ValidateState(); if ((command.CommandBehavior & CommandBehavior.SingleResult) != 0 && resultsRead > 0) { return(false); } try { moreResults = command.Tds.NextResult(); } catch (TdsInternalException ex) { command.Connection.Close(); throw SybaseException.FromTdsInternalException((TdsInternalException)ex); } if (!moreResults) { command.GetOutputParameters(); } else { // new schema - don't do anything except reset schemaTable as command.Tds.Columns is already updated schemaTable = null; dataTypeNames = null; } rowsRead = 0; resultsRead += 1; return(moreResults); }
internal bool ReadRecord() { try { bool result = command.Tds.NextRow(); rowsRead += 1; return(result); } catch (TdsInternalException ex) { command.Connection.Close(); throw SybaseException.FromTdsInternalException((TdsInternalException)ex); } }
public new SybaseDataReader ExecuteReader(CommandBehavior behavior) { ValidateCommand("ExecuteReader"); try { Execute(behavior, true); } catch (TdsTimeoutException e) { throw SybaseException.FromTdsInternalException((TdsInternalException)e); } Connection.DataReader = new SybaseDataReader(this); return(Connection.DataReader); }
void Open() { string serverName = ""; if (connectionString == null || connectionString.Equals("")) { throw new InvalidOperationException("Connection string has not been initialized."); } try { if (!pooling) { ParseDataSource(dataSource, out port, out serverName); tds = new Tds50(serverName, port, PacketSize, ConnectionTimeout); } else { ParseDataSource(dataSource, out port, out serverName); TdsConnectionInfo info = new TdsConnectionInfo(serverName, port, packetSize, ConnectionTimeout, minPoolSize, maxPoolSize); pool = sybaseConnectionPools.GetConnectionPool(connectionString, info); tds = pool.GetConnection(); } } catch (TdsTimeoutException e) { throw SybaseException.FromTdsInternalException((TdsInternalException)e); } tds.TdsErrorMessage += new TdsInternalErrorMessageEventHandler(ErrorHandler); tds.TdsInfoMessage += new TdsInternalInfoMessageEventHandler(MessageHandler); if (!tds.IsConnected) { try { tds.Connect(parms); ChangeState(ConnectionState.Open); ChangeDatabase(parms.Database); } catch { if (pooling) { pool.ReleaseConnection(tds); } throw; } } else if (connectionReset) { // tds.ExecuteNonQuery ("EXEC sp_reset_connection"); FIXME ChangeState(ConnectionState.Open); } }
int ExecuteNonQuery() { ValidateCommand("ExecuteNonQuery"); int result = 0; try { Execute(CommandBehavior.Default, false); result = Tds.RecordsAffected; } catch (TdsTimeoutException e) { throw SybaseException.FromTdsInternalException((TdsInternalException)e); } GetOutputParameters(); return(result); }
object ExecuteScalar() { ValidateCommand("ExecuteScalar"); try { Execute(CommandBehavior.Default, true); } catch (TdsTimeoutException e) { throw SybaseException.FromTdsInternalException((TdsInternalException)e); } if (!Connection.Tds.NextResult() || !Connection.Tds.NextRow()) { return(null); } object result = Connection.Tds.ColumnValues [0]; CloseDataReader(true); return(result); }