FireDAC Components for Sage 300

Build 21.0.7867

SELECT INTO Statements

You can use the SELECT INTO statement to export formatted data to a file.

Data Export with an SQL Query

The following query exports data into a file formatted in comma-separated values (CSV):

SELECT InvoiceUniquifier, ApprovedLimit INTO [csv://OEInvoices.txt] FROM [OEInvoices] WHERE Allowpartialshipments = 'Yes'
You can specify other formats in the file URI. The possible delimiters are tab, semicolon, and comma with the default being a comma. The following example exports tab-separated values:
SELECT InvoiceUniquifier, ApprovedLimit INTO [csv://OEInvoices.txt;delimiter=tab] FROM [OEInvoices] WHERE Allowpartialshipments = 'Yes'

C#

String connectionString = "User=SAMPLE;Password=password;URL=http://127.0.0.1/Sage300WebApi/v1/-/;Company=SAMINC;";

using (Sage300Connection connection = new Sage300Connection(connectionString)) {
  Sage300Command cmd = new Sage300Command("SELECT InvoiceUniquifier, ApprovedLimit INTO [csv://OEInvoices.txt] FROM [OEInvoices] WHERE Allowpartialshipments = 'Yes' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "User=SAMPLE;Password=password;URL=http://127.0.0.1/Sage300WebApi/v1/-/;Company=SAMINC;" 

Using connection As New Sage300Connection(connectionString)
  Dim cmd As New Sage300Command("SELECT InvoiceUniquifier, ApprovedLimit INTO [csv://OEInvoices.txt] FROM [OEInvoices] WHERE Allowpartialshipments = 'Yes'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using
You can specify other file formats in the URI. The following example exports tab-separated values:

C#

String connectionString = "User=SAMPLE;Password=password;URL=http://127.0.0.1/Sage300WebApi/v1/-/;Company=SAMINC;";

using (Sage300Connection connection = new Sage300Connection(connectionString)) {
  Sage300Command cmd = new Sage300Command("SELECT * INTO [OEInvoices] IN [csv://filename=c:/OEInvoices.csv;delimiter=tab] FROM [OEInvoices] WHERE Allowpartialshipments = 'Yes'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "User=SAMPLE;Password=password;URL=http://127.0.0.1/Sage300WebApi/v1/-/;Company=SAMINC;" 

Using connection As New Sage300Connection(connectionString)
  Dim cmd As New Sage300Command("SELECT * INTO [OEInvoices] IN [csv://filename=c:/OEInvoices.csv;delimiter=tab] FROM [OEInvoices] WHERE Allowpartialshipments = 'Yes'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7867