How to use ConnectionException class of NBi.Core package

Best NBi code snippet using NBi.Core.ConnectionException

QueryAdomdEngine.cs

Source:QueryAdomdEngine.cs Github

copy

Full Screen

...89 var connectionString = command.Connection.ConnectionString;90 try91 { connection.ConnectionString = connectionString; }92 catch (ArgumentException ex)93 { throw new ConnectionException(ex, connectionString); }94 //TODO95 //try96 // {connection.Open();}97 //catch (AdomdException ex)98 // {throw new ConnectionException(ex);}99100 Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, command.CommandText);101 foreach (AdomdParameter param in command.Parameters)102 Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, string.Format("{0} => {1}", param.ParameterName, param.Value));103104 // capture time before execution105 DateTime timeBefore = DateTime.Now;106 command.Connection = connection;107 var adapter = new AdomdDataAdapter(command);108 var ds = new DataSet();109 110 adapter.SelectCommand.CommandTimeout = 0;111 try112 {113 adapter.Fill(ds);114 }115 catch (AdomdConnectionException ex)116 {117 throw new ConnectionException(ex, connectionString);118 }119 catch (AdomdErrorResponseException ex)120 {121 throw new ConnectionException(ex, connectionString);122 }123124 // capture time after execution125 DateTime timeAfter = DateTime.Now;126127 // setting query runtime128 elapsedSec = (float) timeAfter.Subtract(timeBefore).TotalSeconds;129 Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, string.Format("Time needed to execute query: {0}", timeAfter.Subtract(timeBefore).ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s")));130131 return ds;132 }133 }134135 /// <summary>136 /// Method exposed by the interface IQueryExecutorFormat to execute a test of execution and get the result of the query executed and also the time needed to retrieve this result137 /// </summary>138 /// <returns>The result of execution of the query</returns>139 public virtual CellSet ExecuteCellSet()140 {141 float i;142 return ExecuteCellSet(out i);143 }144145 /// <summary>146 /// Method exposed by the interface IQueryExecutorFormat to execute a test of execution and get the result of the query executed and also the time needed to retrieve this result147 /// </summary>148 /// <returns>The result of execution of the query</returns>149 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]150 public virtual CellSet ExecuteCellSet(out float elapsedSec)151 {152 // Open the connection153 using (var connection = new AdomdConnection())154 {155 var connectionString = command.Connection.ConnectionString;156 try157 { connection.ConnectionString = connectionString; }158 catch (ArgumentException ex)159 { throw new ConnectionException(ex, connectionString); }160 //TODO161 //try162 // {connection.Open();}163 //catch (AdomdException ex)164 // {throw new ConnectionException(ex);}165166 Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, command.CommandText);167 foreach (AdomdParameter param in command.Parameters)168 Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, string.Format("{0} => {1}", param.ParameterName, param.Value));169170 // capture time before execution171 DateTime timeBefore = DateTime.Now;172 CellSet cellSet = null;173174 try175 {176 if (command.Connection.State != ConnectionState.Open)177 command.Connection.Open();178 cellSet = command.ExecuteCellSet();179 }180 catch (AdomdConnectionException ex)181 {182 throw new ConnectionException(ex, connectionString);183 }184 catch (AdomdErrorResponseException ex)185 {186 throw new ConnectionException(ex, connectionString);187 }188 finally189 {190 if (command.Connection.State == ConnectionState.Open)191 command.Connection.Close();192 }193194 // capture time after execution195 DateTime timeAfter = DateTime.Now;196197 // setting query runtime198 elapsedSec = (float)timeAfter.Subtract(timeBefore).TotalSeconds;199 Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, string.Format("Time needed to execute query: {0}", timeAfter.Subtract(timeBefore).ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s")));200201 return cellSet;202 }203 }204205 public FormattedResults GetFormats()206 {207 var cellSet = ExecuteCellSet();208 var formattedResults = new FormattedResults();209210 foreach (var cell in cellSet.Cells)211 {212 formattedResults.Add(cell.FormattedValue);213 }214 return formattedResults;215 }216217 /// <summary>218 /// Method exposed by the interface IQueryParser to execute a test of syntax on a MDX or SQL statement219 /// </summary>220 /// <remarks>This method makes usage the scommand behaviour named 'SchemaOnly' to not effectively execute the query but check the validity of this query</remarks>221 /// <returns>The result of parsing test</returns>222 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]223 public virtual ParserResult Parse()224 {225 Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, command.CommandText);226 foreach (AdomdParameter param in command.Parameters)227 Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, string.Format("{0} => {1}", param.ParameterName, param.Value));228229 ParserResult res = null;230231 using (var connection = new AdomdConnection())232 {233 var connectionString = command.Connection.ConnectionString;234 try235 {236 connection.ConnectionString = connectionString;237 connection.Open();238 }239 catch (ArgumentException ex)240 { throw new ConnectionException(ex, connectionString); }241 242 using (AdomdCommand cmdIn = new AdomdCommand(command.CommandText, connection))243 {244 foreach (AdomdParameter param in command.Parameters)245 {246 var p = param.Clone();247 cmdIn.Parameters.Add(p);248 }249 try250 {251 cmdIn.ExecuteReader(CommandBehavior.SchemaOnly);252 res = ParserResult.NoParsingError();253 }254 catch (AdomdException ex) ...

Full Screen

Full Screen

AdomdDiscoveryCommand.cs

Source:AdomdDiscoveryCommand.cs Github

copy

Full Screen

...21 protected AdomdCommand CreateCommand()22 {23 var conn = new AdomdConnection();2425 //If connectionString is empty throw a ConnectionException 26 if (String.IsNullOrEmpty(ConnectionString))27 throw new ConnectionException(new ArgumentNullException(), "No connectionString found.");28 conn.ConnectionString = ConnectionString;2930 try31 {32 conn.Open();33 }34 catch (AdomdConnectionException ex)35 {3637 throw new ConnectionException(ex, conn.ConnectionString);38 }394041 var cmd = new AdomdCommand();42 cmd.Connection = conn;43 return cmd;44 }4546 protected AdomdDataReader ExecuteReader(AdomdCommand cmd)47 {48 Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, cmd.CommandText);49 50 AdomdDataReader rdr = null;51 try52 {53 rdr = cmd.ExecuteReader();54 return rdr;55 }56 catch (AdomdConnectionException ex)57 { throw new ConnectionException(ex, cmd.Connection.ConnectionString); }58 catch (AdomdErrorResponseException ex)59 { throw new ConnectionException(ex, cmd.Connection.ConnectionString); }60 }616263 protected void Inform(string text)64 {65 if (ProgressStatusChanged != null)66 ProgressStatusChanged(this, new ProgressStatusEventArgs(text));67 }6869 public IEnumerable<IFilter> Filters {get; set;}70 public abstract IEnumerable<IField> Execute();7172 protected abstract string Build(CaptionFilter filter);73 ...

Full Screen

Full Screen

ConnectionException.cs

Source:ConnectionException.cs Github

copy

Full Screen

...56namespace NBi.Core7{8 /// <summary>9 /// Class handling all the constructor to build a ConnectionException. This exception is specifically managed by the Runtime to display correct and effective information about the issue.10 /// </summary>11 public class ConnectionException : NBiException12 {13 public ConnectionException(ArgumentException ex, string connectionString)14 : this(15 (Exception)ex,16 connectionString17 ) { }1819 public ConnectionException(AdomdErrorResponseException ex, string connectionString)20 : this(21 (Exception)ex,22 connectionString23 ) { }2425 public ConnectionException(AdomdConnectionException ex, string connectionString)26 : this(27 (Exception)ex,28 connectionString29 ) { }3031 public ConnectionException(OleDbException ex, string connectionString)32 : this(33 (Exception)ex,34 connectionString35 ) { }3637 public ConnectionException(SqlException ex, string connectionString)38 : this(39 (Exception)ex,40 connectionString41 ) { }4243 protected ConnectionException(Exception ex, string connectionString)44 : base(45 ex.Message + string.Format("\r\nThe connection string used was '{0}'", connectionString),46 ex.InnerException47 ) { }48 }49} ...

Full Screen

Full Screen

ConnectionException

Using AI Code Generation

copy

Full Screen

1using NBi.Core;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 static void Main(string[] args)10 {11 var conn = new ConnectionException("my connection", "my message");12 Console.WriteLine(conn.Message);13 Console.ReadLine();14 }15 }16}17using NBi.Core;18var conn = new ConnectionException("my connection", "my message");19$connection = New-Object NBi.Core.ConnectionException("my connection", "my message")20Dim conn As New ConnectionException("my connection", "my message")

Full Screen

Full Screen

ConnectionException

Using AI Code Generation

copy

Full Screen

1using NBi.Core;2using NBi.Core;3using NBi.Core;4using NBi.Core;5using NBi.Core;6using NBi.Core;7using NBi.Core;8using NBi.Core;9using NBi.Core;10using NBi.Core;11using NBi.Core;12using NBi.Core;13using NBi.Core;14using NBi.Core;15using NBi.Core;16using NBi.Core;17using NBi.Core;18using NBi.Core;19using NBi.Core;20using NBi.Core;21using NBi.Core;

Full Screen

Full Screen

ConnectionException

Using AI Code Generation

copy

Full Screen

1using NBi.Core;2using NBi.Core.Query;3using NBi.Core.Query.Client;4using NBi.Core.Query.Command;5using NBi.Core.Query.Execution;6using System;7using System.Collections.Generic;8using System.Data;9using System.Data.SqlClient;10using System.Linq;11using System.Text;12using System.Threading.Tasks;13{14 {15 static void Main(string[] args)16 {17 var connectionString = @"Data Source=.\SQL2014;Initial Catalog=AdventureWorks2014;Integrated Security=True";18 var query = "SELECT * FROM Person.Person";19 var command = new QueryCommand(query);20 var client = new AdomdClientFactory().Instantiate(connectionString);21 var executor = new AdomdExecutor(client);22 {23 var result = executor.Execute(command);24 }25 catch (ConnectionException ex)26 {27 throw new ConnectionException(ex);28 }29 }30 }31}

Full Screen

Full Screen

ConnectionException

Using AI Code Generation

copy

Full Screen

1var ex = new NBi.Core.ConnectionException("message");2Console.WriteLine(ex.Message);3var ex = new NBi.Core.ConnectionException("message");4Console.WriteLine(ex.Message);5var ex = new NBi.Core.ConnectionException("message");6Console.WriteLine(ex.Message);7var ex = new NBi.Core.ConnectionException("message");8Console.WriteLine(ex.Message);9var ex = new NBi.Core.ConnectionException("message");10Console.WriteLine(ex.Message);11var ex = new NBi.Core.ConnectionException("message");12Console.WriteLine(ex.Message);13var ex = new NBi.Core.ConnectionException("message");14Console.WriteLine(ex.Message);15var ex = new NBi.Core.ConnectionException("message");16Console.WriteLine(ex.Message);17var ex = new NBi.Core.ConnectionException("message");18Console.WriteLine(ex.Message);19var ex = new NBi.Core.ConnectionException("message");20Console.WriteLine(ex.Message);21var ex = new NBi.Core.ConnectionException("message");22Console.WriteLine(ex.Message);23var ex = new NBi.Core.ConnectionException("message");24Console.WriteLine(ex.Message);25var ex = new NBi.Core.ConnectionException("message");26Console.WriteLine(ex.Message);27var ex = new NBi.Core.ConnectionException("message");28Console.WriteLine(ex.Message);

Full Screen

Full Screen

ConnectionException

Using AI Code Generation

copy

Full Screen

1using NBi.Core;2using NBi.Core.Configuration;3using System.Configuration;4using System.Data.SqlClient;5using System;6using System;7using System.Data.SqlClient;

Full Screen

Full Screen

ConnectionException

Using AI Code Generation

copy

Full Screen

1var ex = new NBi.Core.ConnectionException("Connection error");2Console.WriteLine(ex.Message);3var ex = new NBi.Testing.Core.ConnectionException("Connection error");4Console.WriteLine(ex.Message);5var ex = new NBi.Core.ConnectionException("Connection error");6Console.WriteLine(ex.Message);7var ex = new NBi.Testing.Core.ConnectionException("Connection error");8Console.WriteLine(ex.Message);9var ex = new NBi.Core.ConnectionException("Connection error");10Console.WriteLine(ex.Message);11var ex = new NBi.Testing.Core.ConnectionException("Connection error");12Console.WriteLine(ex.Message);13var ex = new NBi.Core.ConnectionException("Connection error");14Console.WriteLine(ex.Message);15var ex = new NBi.Testing.Core.ConnectionException("Connection error");16Console.WriteLine(ex.Message);17var ex = new NBi.Core.ConnectionException("Connection error");18Console.WriteLine(ex.Message);19var ex = new NBi.Testing.Core.ConnectionException("Connection error");20Console.WriteLine(ex.Message);21var ex = new NBi.Core.ConnectionException("Connection error");22Console.WriteLine(ex.Message);23var ex = new NBi.Testing.Core.ConnectionException("Connection error");24Console.WriteLine(ex.Message);25var ex = new NBi.Core.ConnectionException("Connection error");26Console.WriteLine(ex.Message);27var ex = new NBi.Testing.Core.ConnectionException("Connection error");28Console.WriteLine(ex.Message);

Full Screen

Full Screen

ConnectionException

Using AI Code Generation

copy

Full Screen

1using NBi.Core;2using NBi.Core.Connection;3using NBi.Core.Connection;4using System;5using System.Collections.Generic;6using System.Linq;7using System.Text;8using System.Threading.Tasks;9{10 {11 static void Main(string[] args)12 {13 var connectionManager = new ConnectionManager();14 var connection = new Connection();15 connection.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=True";16 connection.Type = ConnectionType.Sql;17 connectionManager.Connection = connection;18 connectionManager.Test();19 var connectionString = connectionManager.ConnectionString;20 var type = connectionManager.Type;21 var connectionManagerConnectionString = connectionManager.Connection.ConnectionString;22 var connectionManagerType = connectionManager.Connection.Type;23 var connectionManagerConnectionConnectionString = connectionManager.Connection.ConnectionString;24 var connectionManagerConnectionType = connectionManager.Connection.Type;25 var connectionManagerConnection = connectionManager.Connection;26 var connectionManagerConnectionConnectionString = connectionManager.Connection.ConnectionString;27 var connectionManagerConnectionType = connectionManager.Connection.Type;28 }29 }30}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in ConnectionException

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful