TimeSeriesLibrary.TSLibrary.GetConnectionFromId C# (CSharp) Method

GetConnectionFromId() public method

Returns the SqlConnection object corresponding to the given connection number.
public GetConnectionFromId ( int connectionNumber ) : SqlConnection
connectionNumber int serial number of the connection within the collection
return System.Data.SqlClient.SqlConnection
        public SqlConnection GetConnectionFromId(int connectionNumber)
        {
            SqlConnection connx;
            try
            {
                connx = ConnxObject.TSConnectionsCollection[connectionNumber];
            }
            catch
            {
                throw new TSLibraryException(ErrCode.Enum.Connection_Not_Found,
                                String.Format("TimeSeriesLibrary does not have an open connection number {0}",
                                connectionNumber));
            }
            return connx;
        }

Usage Example

Example #1
0
 public SqlConnection GetConnectionFromId(int connectionNumber)
 {
     try
     {
         // let the sibling method in the wrapped TSLibrary object contain the logic
         return(TSLib.GetConnectionFromId(connectionNumber));
     }
     catch (Exception e)
     {
         ErrorMessage = e.Message;
         return(null);
     }
 }