The Visual Studio Integration extension exposes the .NET Data Provider for Teradata objects necessary for development of ADO.NET applications utilizing the Advanced SQL Engine within Microsoft Visual Studio 2015-2022 (Copyright © Microsoft Corporation. All Rights Reserved). Integration includes the following features:
Server Explorer enables viewing and retrieval of information from a database:
Beginning with Teradata database release 12.0, Server Explorer data connections may experience a performance degradation. For more information on this performance degradation and recommendations please see Teradata XView performance considerations.
For more information about the Server Explorer please see:
Right-clicking the Teradata data connection within Server Explorer supports Query Designer through the New Query menu item. Query Designer is a graphical tool that displays tables and views utilized to select columns in building database queries.
Visual Studio Toolbox displays icons from a list of supported items, available from the View menu. Each Toolbox icon may be dragged and dropped onto a design surface, adding the necessary code to create an instance of the object.
The objects provided by .NET Data Provider for Teradata - TdConnection, TdCommand, TdCommandBuilder and TdDataAdapter -- are available items following either the installation of the .NET Data Provider for Teradata or the addition of a reference to Teradata.Client.Provider.dll or a package reference to Teradata.Client.Provider package within the current project.
Toolbox must be configured to include the objects provided by .NET Data Provider for Teradata. To enable the Toolbox display, Visual Studio menu item View -> Toolbox must be selected. Right clicking any Toolbox group and selecting Choose Items, enables customization of the Toolbox.
Select the .NET Framework Components tab and select the Namespace to sort components. Enable the TdCommand, TdConnection, TdCommandBuilder and TdDataAdapter .NET Data Provider for Teradata components found in the Teradata.Client.Provider namespace.
For more information about Visual Studio Toolbox please see: Toolbox.
The objects provided by .NET Data Provider for Teradata - TdConnection, TdCommand, TdCommandBuilder and TdDataAdapter -- may be dragged from the Visual Studio Toolbox and dropped onto a Windows Form. The code to support these objects is automatically generated to create an instantiation of the object.
Datasets, in-memory copies of relational table data and their relationships from supported data sources, are supported in Windows Form projects through right-clicking data sources (Edit Dataset). Creation and population of Datasets are supported through the TdDataAdapter.
The Data Source pane may be enabled by selecting from the Data menu item available in a Windows Form Project items Show Data Sources or Add New Data Source.
Creating a data source will also define a Dataset in which the data source is linked. The Data Source pane displays the Dataset generated during the data source configuration. Right click the Dataset to display Dataset Designer options:
For more information about Dataset Designer please see: Dataset Tools in Visual Studio.
ASP.NET applications and Windows Forms applications may create read/write links from application controls. Data binding enables controls on a Windows Form to retrieve and update Teradata relational data. A summary of the steps to create a data binding to a Teradata table or view follows:
For further information on data binding please see: Bind Windows Forms controls to data.
SQL Server Analysis Services (SSAS) supports Visual Studio integration through a new class of Business Intelligence projects. An Analysis Services project template supports SQL Server Analysis Services. The following features are supported:
For more information about Microsoft SQL Server Analysis Services please see: SQL Server Analysis Services overview.
Microsoft Visual Studio supports Generated Data Retrieval through configuration of the TdDataAdapter in Windows Form Projects. TableAdapters provide communication between your application and a database. A TableAdapter connects to the database and is responsible for executing queries against the database to populate DataTables and to provide synchronization between the DataTable and the database table.
Configuration of the TdDataAdapter in Form Designer - Microsoft Visual Studio Windows projects may configure the TdDataAdapter by dragging and dropping the TdDataAdapter from the Visual Studio Toolbox onto a Windows Form. The Toolbox must be initialized with the .NET Data Provider for Teradata components before dragging and dropping the TdDataAdapter from the Toolbox onto the Windows Form. An icon will appear below the Windows Form. Selecting the TdDataAdapter from the bottom of the Windows Form Designer will display a designer arrow above the TdDataAdapter.
Selecting this arrow and selecting the Configure Data Adapter will enable configuration of the DataAdapter. Please follow the configuration wizard instructions to generate the appropriate commands. Delete and Update commands will only be generated against database tables/views that contain primary keys. After configuration is complete, select the properties of the TdDataAdapter displaying the properties in the property window. Select the insert command property GeneratedDataBehavior and use the drop down list box to select either IdentityColumn or AllColumns. This will enable the defined DataTable to update column values from insert or insert-select statement types executed against the database table.
Configuration of the TdDataAdapter in Dataset Designer - The TdDataAdapter may also be configured utilizing the DataAdapter configuration wizard in the Typed Dataset Designer. A Data Source may be defined by selecting tables or views from Teradata in the Data Sources view. Selecting the Data Source Add a New Data Source button will enable the Data Source configuration wizard. Follow the instructions defining a Teradata Data Source. This will create a Dataset that contains a TableAdapter with generated commands to support your selected database object. Remember that the update and delete commands will only be generated for database tables/views that contain a primary key.
The Configuration of the Data Source will create a Dataset that contains a TableAdapter. To support Generated Data Retrieval, a code modification must be performed to the Dataset designer code. The designer generates code to initialize the TableAdapter. This method InitAdapter () is generated which contains code to initialize the selected commands from the Data Source configuration wizard. The insert command (if selected) needs to define the GeneratedDataBehavior property to enable the DataTable rows to reflect generated data from the database insert or insert-select statement types. This code is a sample generated portion to illustrate the property addition.
C# |
Copy Code |
---|---|
private void InitAdapter() { this._adapter = new Teradata.Client.Provider.TdDataAdapter (); System.Data.Common.DataTableMapping tableMapping = new System.Data.Common.DataTableMapping (); tableMapping.SourceTable = "Table"; tableMapping.DataSetTable = "IdBak"; tableMapping.ColumnMappings.Add ("c1", "c1"); tableMapping.ColumnMappings.Add ("c2", "c2"); tableMapping.ColumnMappings.Add ("c3", "c3"); tableMapping.ColumnMappings.Add ("c4", "c4"); tableMapping.ColumnMappings.Add ("idcol", "idcol"); this._adapter.TableMappings.Add (tableMapping); this._adapter.InsertCommand = new Teradata.Client.Provider.TdCommand (); this._adapter.InsertCommand.Connection = this.Connection; this._adapter.InsertCommand.CommandText = "INSERT INTO \"cc2\".\"idall\" " + "(\"c1\", \"c2\", \"c3\", \"c4\", \"idcol\") " + "VALUES (?, ?, ?, ?, ?)"; this._adapter.InsertCommand.CommandType = System.Data.CommandType.Text; ... } |
Enabling generated data behavior in this DataAdapter requires an additional line of code setting the insert command GeneratedDataBehavior property to either AllColumns or IdentityColumn:
C# |
Copy Code |
---|---|
this._adapter.InsertCommand.GeneratedDataBehavior = Teradata.Client.Provider.GeneratedDataBehavior.AllColumns; |
Example: Creating a data connection in Server Explorer
Use Large Decimal in Typed DataSet