Cmdlets for WooCommerce

Build 20.0.7587

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):

C#

String connectionString = " Url=http://localhost/wordpress/;ConsumerKey=ck_ec52c76185c088ecaa3145287c8acba55a6f59ad;ConsumerSecret=cs_9fde14bf57126156701a7563fc87575713c355e5;";

using (WooCommerceConnection connection = new WooCommerceConnection(connectionString)) {
  WooCommerceCommand cmd = new WooCommerceCommand("SELECT ParentId, Total INTO [csv://Orders.txt] FROM [Orders] WHERE ParentId = '3' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = " Url=http://localhost/wordpress/;ConsumerKey=ck_ec52c76185c088ecaa3145287c8acba55a6f59ad;ConsumerSecret=cs_9fde14bf57126156701a7563fc87575713c355e5;" 

Using connection As New WooCommerceConnection(connectionString)
  Dim cmd As New WooCommerceCommand("SELECT ParentId, Total INTO [csv://Orders.txt] FROM [Orders] WHERE ParentId = '3'", 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 = " Url=http://localhost/wordpress/;ConsumerKey=ck_ec52c76185c088ecaa3145287c8acba55a6f59ad;ConsumerSecret=cs_9fde14bf57126156701a7563fc87575713c355e5;";

using (WooCommerceConnection connection = new WooCommerceConnection(connectionString)) {
  WooCommerceCommand cmd = new WooCommerceCommand("SELECT * INTO [Orders] IN [csv://filename=c:/Orders.csv;delimiter=tab] FROM [Orders] WHERE ParentId = '3'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = " Url=http://localhost/wordpress/;ConsumerKey=ck_ec52c76185c088ecaa3145287c8acba55a6f59ad;ConsumerSecret=cs_9fde14bf57126156701a7563fc87575713c355e5;" 

Using connection As New WooCommerceConnection(connectionString)
  Dim cmd As New WooCommerceCommand("SELECT * INTO [Orders] IN [csv://filename=c:/Orders.csv;delimiter=tab] FROM [Orders] WHERE ParentId = '3'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7587