CData Excel Add-In for USPS 2019J - Online Help

SELECT INTO ステートメント

CData Excel Add-In for USPS 2019J - Build 19.0.7354

SELECT INTO ステートメントを使って、書式付きデータをファイルにエクスポートできます。

SQL クエリを使ったデータのエクスポート

次のクエリは、comma-separated values(CSV)ファイルフォーマットにデータをエクスポートします。

SELECT FirstName, Phone INTO [csv://Senders.txt] FROM [Senders] WHERE SenderID = '25'
ファイルURI で他のフォーマットを指定できます。利用可能な区切り文字はタブ、セミコロン、カンマです。デフォルトはカンマです。次の例は、tab-separated values(TSV)にエクスポートします。
SELECT FirstName, Phone INTO [csv://Senders.txt;delimiter=tab] FROM [Senders] WHERE SenderID = '25'

C#

String connectionString = "PostageProvider=ENDICIA;RequestId=11037;Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\uspscache';";

using (USPSConnection connection = new USPSConnection(connectionString)) {
  USPSCommand cmd = new USPSCommand("SELECT FirstName, Phone INTO [csv://Senders.txt] FROM [Senders] WHERE SenderID = '25' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "PostageProvider=ENDICIA;RequestId=11037;Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\uspscache';" 

Using connection As New USPSConnection(connectionString)
  Dim cmd As New USPSCommand("SELECT FirstName, Phone INTO [csv://Senders.txt] FROM [Senders] WHERE SenderID = '25'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using
URI で他のファイルフォーマットを指定できます。以下の例は、tab-separated values(TSV)にエクスポートします。

C#

String connectionString = "PostageProvider=ENDICIA;RequestId=11037;Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\uspscache';";

using (USPSConnection connection = new USPSConnection(connectionString)) {
  USPSCommand cmd = new USPSCommand("SELECT * INTO [Senders] IN [csv://filename=c:/Senders.csv;delimiter=tab] FROM [Senders] WHERE SenderID = '25'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "PostageProvider=ENDICIA;RequestId=11037;Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\uspscache';" 

Using connection As New USPSConnection(connectionString)
  Dim cmd As New USPSCommand("SELECT * INTO [Senders] IN [csv://filename=c:/Senders.csv;delimiter=tab] FROM [Senders] WHERE SenderID = '25'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

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