# Getting Started

## Content



The **ADO.NET provider for Magento** provides a wide range of features that enable connectivity to Magento from .Net applications. The documentation will help you understand the [C1.AdoNet.Magento](/componentone/api/services/online-dataconnector/dotnet-standard-api/C1.AdoNet.Magento/Assembly) namespace, which includes all the available classes that can be used to connect and retrieve data from a Magento service.

DataConnectors are mostly used in combination with other ComponentOne components, such as DataEngine and FlexPivot. The procedure below describes how to use the DataConnector in a console application within Visual Studio.

### How to create a new Console Application

The ADO.NET provider for Magento can be used in any application. In this guide, a console application is created:

1.  Open **Visual Studio**.
2.  Select **Create a new project** from the **Get Started** pane.
3.  In the **Create a new project** window, select **Console Application** and click **Next**, as in the screenshot below: ![Create new project window](https://cdn.mescius.io/document-site-files/images/0d302e1a-ed9a-4636-b2ab-ee6e2f9613d8/images/consoleapp.png)
4.  In the **Configure your new project** window, write your project name, choose a location to save your project, and click **Create**.

### How to add the NuGet packages

To use the ADO.NET provider for Magento in an application, the respective NuGet package should be added:

1.  From the **Project** menu, select **Manage NuGet Packages**.
2.  In the **NuGet Package** Manager, click the **Package source** drop-down and select **nuget.org**
3.  In the **left** pane of the **Browse** tab, select **C1.AdoNet.Magento**
4.  In the **right** pane of the **Browse** tab, click **Install** to add the reference to the package.

### How to use ADO.Net provider for Magento to retrieve data

Follow the steps provided below to learn and implement data retrieval using the ADO.NET provider for Magento.

1.  Create a connection string to set up a connection to a Magento instance by setting the properties.
    
    ```csharp
    //Define connection string
    string connectionString = @"Url = http://****/****/****, Username= yourusername; Password= yourpassword; Token Type= TokenType;
    ```
    
2.  Fetch the data using [C1MagentoConnection](/componentone/api/services/online-dataconnector/dotnet-standard-api/C1.AdoNet.Magento/C1.AdoNet.Magento.C1MagentoConnection.html) class. The connection string using corresponding attributes is passed as an argument. For more information on creating connections, see [Creating Connection](/componentone/docs/services/online-dataconnector/ado.net-provider-for-magento/magentoconnection). **C1MagentoConnection** implements the ADO.NET DbConnection, similar to standard ADO.NET connection object that retrieves a single result set of all the data that matches a query. Once the connection is established, it retrieves the data from the source as shown in the following **code example.**
    
    ```csharp
    using (C1MagentoConnection conn = new C1MagentoConnection(MagentoConnection))
        {
            //Populate DataTable                
            C1MagentoDataAdapter adapter = new C1MagentoDataAdapter(conn, "Select id, name, price, visibility from products");
            DataTable dataTable = new DataTable();
            var i = adapter.Fill(dataTable);
            if (i != -1)
            {
                //Display fetched data
                foreach (DataRow row in dataTable.Rows)
                {
                    Console.WriteLine("Product Id:{0}", row["id"]);
                    Console.WriteLine("Product Name:{0}", row["name"]);
                    Console.WriteLine("Price:{0}", row["price"]);
                    Console.WriteLine("Visibility:{0}", row["visibility"]);
                    Console.WriteLine("\n");
                }
                Console.WriteLine("Read operation successful !!! \n \n");
            }
        }
    ```
    

The following output is generated on the console application on executing the above steps.

![](https://cdn.mescius.io/document-site-files/images/0d302e1a-ed9a-4636-b2ab-ee6e2f9613d8/images/magentooutput.png)