ADO.NET Provider for UPS

Build 21.0.7930

SELECT INTO ステートメント

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

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

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

C#

String connectionString = "Server='https://wwwcie.ups.com/ups.app/xml';AccessKey='346DAC9059AF258';Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';UserId='alsdkfjpqoewiru';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\upscache';";

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

VB.NET

Dim connectionString As [String] = "Server='https://wwwcie.ups.com/ups.app/xml';AccessKey='346DAC9059AF258';Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';UserId='alsdkfjpqoewiru';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\upscache';" 

Using connection As New UPSConnection(connectionString)
  Dim cmd As New UPSCommand("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 = "Server='https://wwwcie.ups.com/ups.app/xml';AccessKey='346DAC9059AF258';Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';UserId='alsdkfjpqoewiru';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\upscache';";

using (UPSConnection connection = new UPSConnection(connectionString)) {
  UPSCommand cmd = new UPSCommand("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] = "Server='https://wwwcie.ups.com/ups.app/xml';AccessKey='346DAC9059AF258';Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';UserId='alsdkfjpqoewiru';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\upscache';" 

Using connection As New UPSConnection(connectionString)
  Dim cmd As New UPSCommand("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) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930