Connect To Any Database From .NET Core Using DataDirect ODBC ...

skip navigation AIProgress Agentic RAGNewAI Product Overview AI Thought LeadershipSolutionsArtificial Intelligence

Develop the responsible AI-powered applications and experiences you need, deploy them where and how you want and manage it all with Progress AI-driven products.

Data Platform

Accelerate data, AI and analytics projects, manage costs and deliver enterprise growth with the Progress Data Platform.

Digital Experience

Real solutions for your organization and end users built with best of breed offerings, configured to be flexible and scalable with you.

Infrastructure Management

Progress infrastructure management products speed the time and reduce the effort required to manage your network, applications and underlying infrastructure.

Federal Solutions

Software products and services for federal government, defense and public sector.

ProductsData Platform Agentic RAGNewMarkLogic Semaphore OpenEdge DataDirect CorticonDigital Experience Sitefinity Telerik Kendo UI Corticon DataDirect ShareFile Podio MOVEitDevOps Chef Infrastructure Management & Operations Flowmon Kemp LoadMaster WhatsUp GoldUI/UX Tools Telerik Kendo UI Fiddler Test Studio Document collaboration and File Transfer ShareFile Automate MFTNewMOVEit WS_FTPView All ProductsSupportSupport By Product Customer Portal Download Center Support Guide CommunityServicesResourcesResources Resource Center Papers Webinars Videos Documentation Knowledge Base Blogs Events Customer Stories FAQsTrainingInstructor-Led Training On-Demand TrainingPartnersFind a Partner Become a Partner Partner Login Deal RegistrationNewCompanyAbout ProgressCompany Overview Leadership Corporate Development Corporate Social Responsibility Federal SolutionsNews & InfoInvestor Relations Press Releases Trust Center Careers OfficesSite search Search UserSupportLink PartnerLink Telerik Your Account1-800-477-6473 Ready to Talk?Site search GO
  • Overview
  • Data Connectivity
    • Explore All Products Data Products Data Connectors Hybrid Data Pipeline Autonomous REST Connector OpenAccess SDK Custom connectors Interface ODBC Drivers JDBC Drivers ADO.NET Drivers OData REST APIs Use Cases Salesforce Popular BI and Analytics Power BI SAS Analytics Tableau Microsoft SQL Server AWS Glue Explore All Use Cases
  • Salesforce Connectivity
  • Software Vendors
  • Resources
    • Resource Center
    • Blogs Customers Whitepapers Webinars Customer Validation Program FAQs Download Center Trust Center
    • How-To Videos Documentation Tutorials Knowledge Base Product Compatibility Guide Release Notes Enhancement Requests Community
  • Pricing
Contact UsTry Now ODBC TUTORIAL Connect to Any Database from .NET Core Using DataDirect ODBC Connectors on Windows Updated: 31 Jul 2024

Introduction

In this tutorial, we will walk through how to connect to any database from .NET Core using Progress DataDirect’s ODBC Connectors on Windows. This tutorial uses Progress DataDirect’s ODBC Driver for Apache Hadoop Hive to demonstrate how to connect to it from .NET Core, but the same steps can be applied to any of our ODBC Connectors.

Install Progress DataDirect ODBC Connectors

  1. Download Progress DataDirect’s ODBC Driver for Apache Hadoop Hive or any other ODBC driver.
  2. Install the ODBC connector by running the executable.

Determining the ODBC Driver name

  1. Open ODBC Administrator and Click on Add. In this window, find the DataDirect ODBC connector we installed to connect to the database.
  2. Find the full driver name there and keep note of it. 2

Install System.Data.Odbc Nuget Package

  1. Create a New .NET Core project or use an existing .NET Core project.
  2. If using Visual Studio, install the package in the project by running the below command in the Package Manager console in Visual Studio Install-Package System.Data.Odbc -Version 4.7.0
  3. If using Terminal, run the below command in the project space to install the package dotnet add package System.Data.Odbc --version 4.7.0

Connecting to Database

  1. Below is a simple program to connect to the Hive instance. Using Progress DataDirect’s ODBC Connector, run a SQL query and print the results. using System; using System.Data.Odbc; namespace DataDirectODBCConnect { class Program { static void Main(string[] args) { OdbcConnectionStringBuilder builder = new OdbcConnectionStringBuilder { Driver = "DataDirect 8.0 Apache Hive Wire Protocol" }; builder.Add("HostName", "192.168.1.1"); builder.Add("PortNumber", "10000"); builder.Add("Database", "mydb"); builder.Add("UID", "username"); builder.Add("PWD", "password"); using (OdbcConnection connection = new OdbcConnection(builder.ConnectionString)) { string sqlQuery = "SELECT activityid, emailaddress, activitydate FROM emails limit 100"; OdbcCommand command = new OdbcCommand(sqlQuery, connection); connection.Open(); OdbcDataReader reader = command.ExecuteReader(); //Print Column Names for (int i=0; i< reader.FieldCount; i++) { Console.Write(reader.GetName(i) + "\t"); } Console.Write("\n"); if(reader.HasRows) { while(reader.Read()) { Console.WriteLine("{0}\t{1}\t{2}", reader.GetInt32(0), reader.GetString(1), reader.GetString(2)); } } reader.Close(); command.Dispose(); } } } }
  2. If using a different Progress DataDirect ODBC connector, replace the Driver name, Connection string configuration as needed.
  3. Build the solution and run it. The data will print on your console. 3

    We hope this tutorial helped you to connect to Hive from .NET Core using Progress DataDirect’s ODBC Driver for Apache Hadoop Hive. Feel free to download any Progress DataDirect ODBC connector and try it out. Please contact us with any questions and we will be happy to help.

Contents
  • Introduction
  • Install Progress DataDirect ODBC Connectors
  • Determining the ODBC Driver name
  • Install System.Data.Odbc Nuget Package
  • Connecting to Database

Connect any application to any data source anywhere

Explore all DataDirect Connectors

Need additional help with your product?

Get Customer Support

Tag » How To Connect To Database Using Odbc.net