How to use OleDbClientFactory class of NBi.Core.Query.Client package

Best NBi code snippet using NBi.Core.Query.Client.OleDbClientFactory

OleDbClientFactoryTest.cs

Source:OleDbClientFactoryTest.cs Github

copy

Full Screen

...13#endregion14namespace NBi.Testing.Core.Query.Client15{16 [TestFixture]17 public class OleDbClientFactoryTest18 {19 #region SetUp & TearDown20 //Called only at instance creation21 [OneTimeSetUp]22 public void SetupMethods()23 {24 }25 //Called only at instance destruction26 [OneTimeTearDown]27 public void TearDownMethods()28 {29 }30 //Called before each test31 [SetUp]32 public void SetupTest()33 {34 }35 //Called after each test36 [TearDown]37 public void TearDownTest()38 {39 }40 #endregion41 [Test]42 public void Get_OleDb_OledbConnection()43 {44 var connStr = "Provider=OledB;Data Source=ds;Initial Catalog=ic";45 var actual = new OleDbClientFactory().Instantiate(connStr);46 Assert.That(actual, Is.InstanceOf<DbClient>());47 Assert.That(actual.ConnectionString, Is.EqualTo(connStr));48 var conn = actual.CreateNew();49 Assert.That(conn, Is.InstanceOf<OleDbConnection>());50 Assert.That((conn as OleDbConnection).ConnectionString, Is.EqualTo(connStr));51 }52 [Test]53 public void Get_SqlOleDb_OledbConnection()54 {55 var connStr = "Provider=sqlOledB;Data Source=ds;Initial Catalog=ic";56 var actual = new OleDbClientFactory().Instantiate(connStr);57 Assert.That(actual, Is.InstanceOf<DbClient>());58 Assert.That(actual.ConnectionString, Is.EqualTo(connStr));59 var conn = actual.CreateNew();60 Assert.That(conn, Is.InstanceOf<OleDbConnection>());61 Assert.That((conn as OleDbConnection).ConnectionString, Is.EqualTo(connStr));62 }63 [Test]64 public void Get_SqlNCli_OleDbConnection()65 {66 var connStr = "Provider=SQLNCLI;Data Source=ds;Initial Catalog=ic";67 var actual = new OleDbClientFactory().Instantiate(connStr);68 Assert.That(actual, Is.InstanceOf<DbClient>());69 Assert.That(actual.ConnectionString, Is.EqualTo(connStr));70 var conn = actual.CreateNew();71 Assert.That(conn, Is.InstanceOf<OleDbConnection>());72 Assert.That((conn as OleDbConnection).ConnectionString, Is.EqualTo(connStr));73 }74 [Test]75 public void Get_SqlNCli10Dot1_OleDbConnection()76 {77 var connStr = "Provider=SQLNCLI10.1;Data Source=ds;Initial Catalog=ic;Integrated Security=SSPI;";78 var actual = new OleDbClientFactory().Instantiate(connStr);79 Assert.That(actual, Is.InstanceOf<DbClient>());80 Assert.That(actual.ConnectionString, Is.EqualTo(connStr));81 var conn = actual.CreateNew();82 Assert.That(conn, Is.InstanceOf<OleDbConnection>());83 Assert.That((conn as OleDbConnection).ConnectionString, Is.EqualTo(connStr));84 }85 [Test]86 public void Get_SqlNCli11Dot1_OleDbConnection()87 {88 var connStr = "Provider=SQLNCLI11.1;Data Source=.;Initial Catalog=AdventureWorks2014;Integrated Security=SSPI";89 var actual = new OleDbClientFactory().Instantiate(connStr);90 Assert.That(actual, Is.InstanceOf<DbClient>());91 Assert.That(actual.ConnectionString, Is.EqualTo(connStr));92 var conn = actual.CreateNew();93 Assert.That(conn, Is.InstanceOf<OleDbConnection>());94 Assert.That((conn as OleDbConnection).ConnectionString, Is.EqualTo(connStr));95 }96 [Test]97 public void Get_ConnectionStringOleDbProvider_OleDbConnection()98 {99 var connStr = "Provider=OleDb.1;Data Source=ds;Initial Catalog=ic;Integrated Security=SSPI;";100 var actual = new OleDbClientFactory().Instantiate(connStr);101 Assert.That(actual, Is.InstanceOf<DbClient>());102 Assert.That(actual.ConnectionString, Is.EqualTo(connStr));103 var conn = actual.CreateNew();104 Assert.That(conn, Is.InstanceOf<OleDbConnection>());105 Assert.That((conn as OleDbConnection).ConnectionString, Is.EqualTo(connStr));106 }107 [Test]108 public void Get_OleDbExcel_OleDbConnection()109 {110 //Call the method to test111 var connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\myFolder\\myExcel2007file.xlsx;Extended Properties=\"Excel 12.0 Xml;HDR=YES\";";112 113 var factory = new OleDbClientFactory();114 var actual = factory.Instantiate(connStr);115 //Assertion116 Assert.That(actual, Is.InstanceOf<DbClient>());117 Assert.That(actual.ConnectionString, Is.EqualTo(connStr));118 var conn = actual.CreateNew();119 Assert.That(conn, Is.InstanceOf<OleDbConnection>());120 Assert.That((conn as OleDbConnection).ConnectionString, Is.EqualTo(connStr));121 }122 }123}...

Full Screen

Full Screen

ClientProvider.cs

Source:ClientProvider.cs Github

copy

Full Screen

...16 typeof(AdomdClientFactory),17 typeof(OdbcClientFactory),18 typeof(SqlClientFactory),19 typeof(PowerBiDesktopClientFactory),20 typeof(OleDbClientFactory), //It's important to keep this one as the last one because it will handle all the connectionStrings with a provider21 };22 public ClientProvider()23 {24 RegisterFactories(classics);25 }26 public ClientProvider(IExtensionsConfiguration config)27 {28 var extensions = config?.Extensions?.Where(x => typeof(IClientFactory).IsAssignableFrom(x.Key) && !x.Key.IsAbstract)?.Select(x => x.Key) ?? new Type[0];29 RegisterFactories(classics.Union(extensions).ToArray());30 }31 protected internal void RegisterFactories(Type[] types)32 {33 foreach (var type in types)34 {...

Full Screen

Full Screen

OleDbClientFactory.cs

Source:OleDbClientFactory.cs Github

copy

Full Screen

...9using System.Threading.Tasks;10using NBi.Extensibility.Query;11namespace NBi.Core.Query.Client12{13 class OleDbClientFactory : DbClientFactory14 {15 public OleDbClientFactory() 16 : base()17 { }18 protected override IClient Instantiate(DbProviderFactory factory, string connectionString)19 => new DbClient(factory, typeof(OleDbConnection), connectionString);20 protected override DbProviderFactory ParseConnectionString(string connectionString)21 {22 var csb = GetConnectionStringBuilder(connectionString);23 if (csb == null)24 return null;25 var providerName = ExtractProviderName(csb, connectionString);26 if (string.IsNullOrEmpty(providerName))27 return null;28 29 var factory = GetDbProviderFactory("System.Data.OleDb");...

Full Screen

Full Screen

OleDbClientFactory

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Query.Client;2using System;3using System.Collections.Generic;4using System.Data;5using System.Data.OleDb;6using System.Linq;7using System.Text;8using System.Threading.Tasks;9{10 {11 public IDbConnection Instantiate(string connectionString)12 {13 return new OleDbConnection(connectionString);14 }15 public IDbCommand InstantiateCommand()16 {17 return new OleDbCommand();18 }19 public IDbDataAdapter InstantiateDataAdapter()20 {21 return new OleDbDataAdapter();22 }23 public IDbDataParameter InstantiateParameter()24 {25 return new OleDbParameter();26 }27 }28}29using NBi.Core.Query.Client;30using System;31using System.Collections.Generic;32using System.Data;33using System.Data.OleDb;34using System.Linq;35using System.Text;36using System.Threading.Tasks;37{38 {39 public IDbConnection Instantiate(string connectionString)40 {41 return new OleDbConnection(connectionString);42 }43 public IDbCommand InstantiateCommand()44 {45 return new OleDbCommand();46 }47 public IDbDataAdapter InstantiateDataAdapter()48 {49 return new OleDbDataAdapter();50 }51 public IDbDataParameter InstantiateParameter()52 {53 return new OleDbParameter();54 }55 }56}57using NBi.Core.Query.Client;58using System;59using System.Collections.Generic;60using System.Data;61using System.Data.OleDb;62using System.Linq;63using System.Text;64using System.Threading.Tasks;65{66 {67 public IDbConnection Instantiate(string connectionString)68 {69 return new OleDbConnection(connectionString);70 }71 public IDbCommand InstantiateCommand()72 {73 return new OleDbCommand();74 }75 public IDbDataAdapter InstantiateDataAdapter()76 {77 return new OleDbDataAdapter();78 }79 public IDbDataParameter InstantiateParameter()80 {81 return new OleDbParameter();82 }83 }84}85using NBi.Core.Query.Client;86using System;87using System.Collections.Generic;88using System.Data;89using System.Data.OleDb;90using System.Linq;

Full Screen

Full Screen

OleDbClientFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Data;3using System.Data.OleDb;4using NBi.Core.Query.Client;5{6 public static void Main()7 {8 OleDbClientFactory factory = new OleDbClientFactory();9 IDbConnection connection = factory.Instantiate("Provider=SQLOLEDB.1;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=SSPI;");10 connection.Open();11 IDbCommand command = factory.InstantiateCommand();12 command.Connection = connection;13 command.CommandText = "SELECT * FROM Person.Person";14 IDataReader reader = command.ExecuteReader();15 while (reader.Read())16 {17 Console.WriteLine(reader["FirstName"]);18 }19 reader.Close();20 connection.Close();21 }22}

Full Screen

Full Screen

OleDbClientFactory

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Query.Client;2using System;3using System.Data;4using System.Data.OleDb;5using System.Data.Common;6using System.Configuration;7{8 {9 static void Main(string[] args)10 {11 DbProviderFactory factory = OleDbClientFactory.Instance;12 DbConnection conn = factory.CreateConnection();13 conn.ConnectionString = ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;14 conn.Open();15 DbCommand cmd = conn.CreateCommand();16 cmd.CommandText = "SELECT * FROM [Customers]";17 DbDataReader reader = cmd.ExecuteReader();18 while (reader.Read())19 {20 Console.WriteLine(reader[0]);21 }22 conn.Close();23 }24 }25}

Full Screen

Full Screen

OleDbClientFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Data;3using System.Data.OleDb;4using NBi.Core.Query.Client;5{6 {7 static void Main(string[] args)8 {9 OleDbConnection conn = new OleDbConnection();10 conn.ConnectionString = "Provider=SQLOLEDB.1;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=SSPI;";11 conn.Open();12 OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Person].[Person]", conn);13 OleDbDataReader dr = cmd.ExecuteReader();14 while (dr.Read())15 {16 Console.WriteLine(dr["FirstName"]);17 }18 conn.Close();19 }20 }21}

Full Screen

Full Screen

OleDbClientFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Data.OleDb;3using System.Data;4using NBi.Core.Query.Client;5using NBi.Core.Query;6using NBi.Core.Query.Resolver;7using NBi.Core.Query.Command;8using NBi.Core.Query.Execution;9using NBi.Core.Query.Parameters;10using NBi.Core.Query.Resolver.Csv;11using NBi.Core.Query.Resolver.Variables;12using NBi.Core.Query.Resolver.File;13using NBi.Core.Query.Resolver.Providers;14using NBi.Core.Query.Resolver.Providers;15using NBi.Core.Query.Resolver.Providers.Csv;16using NBi.Core.Query.Resolver.Providers.File;17using NBi.Core.Query.Resolver.Providers.Sql;18using NBi.Core.Query.Resolver.Providers.Xml;19using NBi.Core.Query.Resolver.Providers.OleDb;20using NBi.Core.Query.Resolver.Providers.Odbc;21using NBi.Core.Query.Resolver.Providers.Json;22using NBi.Core.Query.Resolver.Providers.JsonPath;23using NBi.Core.Query.Resolver.Providers.Tsv;24using NBi.Core.Query.Resolver.Providers.TsvPath;25using NBi.Core.Query.Resolver.Providers.Presto;26using NBi.Core.Query.Resolver.Providers.MySql;27using NBi.Core.Query.Resolver.Providers.PgSql;28using NBi.Core.Query.Resolver.Providers.SQLite;29using NBi.Core.Query.Resolver.Providers.Excel;30using NBi.Core.Query.Resolver.Providers.Access;31using NBi.Core.Query.Resolver.Providers.SqLite;32using NBi.Core.Query.Resolver.Providers.BigQuery;33using NBi.Core.Query.Resolver.Providers.SqLiteCipher;34using NBi.Core.Query.Resolver.Providers.Redshift;35using NBi.Core.Query.Resolver.Providers.Ado;36using NBi.Core.Query.Resolver.Providers.MongoDb;37using NBi.Core.Query.Resolver.Providers.SqlServer;38using NBi.Core.Query.Resolver.Providers.SqLiteEpoxy;39using NBi.Core.Query.Resolver.Providers.SqLiteMdf;40using NBi.Core.Query.Resolver.Providers.SqLitePcl;41using NBi.Core.Query.Resolver.Providers.SqLiteStandard;42using NBi.Core.Query.Resolver.Providers.SqLiteSystemData;43using NBi.Core.Query.Resolver.Providers.SqLiteUwp;44using NBi.Core.Query.Resolver.Providers.SqLiteWinRt;

Full Screen

Full Screen

OleDbClientFactory

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Query.Client;2var factory = new OleDbClientFactory();3var client = factory.Instantiate("Provider=SQLOLEDB;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=SSPI;");4using NBi.Core.Query.Client;5var factory = new OleDbClientFactory();6var client = factory.Instantiate("Provider=SQLOLEDB;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=SSPI;");7using NBi.Core.Query.Client;8var factory = new OleDbClientFactory();9var client = factory.Instantiate("Provider=SQLOLEDB;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=SSPI;");10using NBi.Core.Query.Client;11var factory = new OleDbClientFactory();12var client = factory.Instantiate("Provider=SQLOLEDB;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=SSPI;");13using NBi.Core.Query.Client;14var factory = new OleDbClientFactory();15var client = factory.Instantiate("Provider=SQLOLEDB;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=SSPI;");16using NBi.Core.Query.Client;17var factory = new OleDbClientFactory();18var client = factory.Instantiate("Provider=SQLOLEDB;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=SSPI;");19using NBi.Core.Query.Client;20var factory = new OleDbClientFactory();21var client = factory.Instantiate("Provider=SQLOLEDB;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=SSPI;");22using NBi.Core.Query.Client;

Full Screen

Full Screen

OleDbClientFactory

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Query.Client;2using System;3using System.Data;4using System.Data.OleDb;5using System.Data.SqlClient;6using System.IO;7using System.Reflection;8using System.Text;9using System.Threading.Tasks;10using System.Windows.Forms;11{12 {13 public Form1()14 {15 InitializeComponent();16 }17 private void Form1_Load(object sender, EventArgs e)18 {19 var factory = new OleDbClientFactory();20 var connectionString = @"Provider=SQLNCLI11;Server=.;Database=AdventureWorks2014;Trusted_Connection=yes;";21 var commandText = "SELECT * FROM Person.Person";22 var results = factory.ExecuteQuery(connectionString, commandText);23 using (var stream = new MemoryStream())24 {25 results.WriteXml(stream);26 stream.Position = 0;27 using (var reader = new StreamReader(stream))28 {29 var content = reader.ReadToEnd();30 MessageBox.Show(content);31 }32 }33 }34 }35}36Error: System.Data.OleDb.OleDbException (0x80004005): Unspecified error37using System;38using System.Data;39using System.Data.OleDb;40using System.Data.SqlClient;41using System.IO;42using System.Reflection;43using System.Text;44using System.Threading.Tasks;45using System.Windows.Forms;46{47 {48 public Form1()49 {50 InitializeComponent();51 }52 private void Form1_Load(object sender, EventArgs e)53 {54 var connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Amit\Desktop\AdventureWorks2014.mdb";55 var commandText = "SELECT * FROM Person.Person";56 var results = new DataTable();57 using (var connection = new OleDbConnection(connectionString))58 {59 connection.Open();60 using (var command = new OleDbCommand(commandText, connection))61 {62 using (var reader = command.ExecuteReader())63 {64 results.Load(reader);65 }66 }67 }68 using (var stream = new MemoryStream())69 {70 results.WriteXml(stream);71 stream.Position = 0;72 using (var reader = new StreamReader(stream))

Full Screen

Full Screen

OleDbClientFactory

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Query.Client;2using System;3using System.Data;4using System.Data.OleDb;5{6 {7 static void Main(string[] args)8 {9 string connectionString = "Provider=MSOLAP;Data Source=.;Initial Catalog=Adventure Works DW Standard Edition;Cube Name=Adventure Works";10 IDbConnection connection = OleDbClientFactory.Instance.CreateConnection();11 connection.ConnectionString = connectionString;12 connection.Open();13 IDbCommand command = connection.CreateCommand();14 command.CommandText = "select [Measures].[Customer Count] on columns from [Adventure Works]";15 IDataReader reader = command.ExecuteReader();16 while (reader.Read())17 {18 Console.WriteLine(reader[0]);19 }20 connection.Close();21 }22 }23}

Full Screen

Full Screen

OleDbClientFactory

Using AI Code Generation

copy

Full Screen

1var factory = new OleDbClientFactory();2var connection = factory.Instantiate("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\xxx\\Desktop\\1.xlsx;Extended Properties=\"Excel 12.0 Xml;HDR=YES;\"");3var command = factory.BuildCommand(connection, "select * from [Sheet1$]");4var reader = command.ExecuteReader();5while (reader.Read())6{7 Console.WriteLine(reader.GetString(0));8}9var command = factory.BuildCommand(connection, "select * from [Sheet1$]");10var reader = command.ExecuteReader();11while (reader.Read())12{13 Console.WriteLine(reader.GetString(0));14}15var command = factory.BuildCommand(connection, "select * from [Sheet1$]");16var reader = command.ExecuteReader();17while (reader.Read())18{19 Console.WriteLine(reader.GetString(0));20}21var command = factory.BuildCommand(connection, "select * from [Sheet1$]");22var reader = command.ExecuteReader();23while (reader.Read())24{25 Console.WriteLine(reader.GetString(0));26}27var command = factory.BuildCommand(connection, "select * from [Sheet1$]");28var reader = command.ExecuteReader();29while (reader.Read())30{31 Console.WriteLine(reader.GetString(0));32}33var command = factory.BuildCommand(connection, "select * from [Sheet1$]");34var reader = command.ExecuteReader();35while (reader.Read())36{37 Console.WriteLine(reader.GetString(0));38}39var command = factory.BuildCommand(connection, "select * from [Sheet1$]");40var reader = command.ExecuteReader();41while (reader.Read())42{43 Console.WriteLine(reader.GetString(0));44}45var command = factory.BuildCommand(connection, "select * from [Sheet1$]");46var reader = command.ExecuteReader();47while (reader.Read())48{49 Console.WriteLine(reader.GetString(0));50}51var command = factory.BuildCommand(connection, "select * from [Sheet1$]");52var reader = command.ExecuteReader();53while (reader.Read())54{55 Console.WriteLine(reader.GetString(0));56}

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful