ADO.NET Provider for Autify

Build 21.0.7930

SELECT INTO ステートメント

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

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

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

C#

String connectionString = "ProjectId=255;ApiKey=M9e88D3s31b35347EgNVa;";

using (AutifyConnection connection = new AutifyConnection(connectionString)) {
  AutifyCommand cmd = new AutifyCommand("SELECT Name, ProjectURL INTO [csv://Scenarios.txt] FROM [Scenarios] WHERE Id = '46292' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "ProjectId=255;ApiKey=M9e88D3s31b35347EgNVa;" 

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

C#

String connectionString = "ProjectId=255;ApiKey=M9e88D3s31b35347EgNVa;";

using (AutifyConnection connection = new AutifyConnection(connectionString)) {
  AutifyCommand cmd = new AutifyCommand("SELECT * INTO [Scenarios] IN [csv://filename=c:/Scenarios.csv;delimiter=tab] FROM [Scenarios] WHERE Id = '46292'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "ProjectId=255;ApiKey=M9e88D3s31b35347EgNVa;" 

Using connection As New AutifyConnection(connectionString)
  Dim cmd As New AutifyCommand("SELECT * INTO [Scenarios] IN [csv://filename=c:/Scenarios.csv;delimiter=tab] FROM [Scenarios] WHERE Id = '46292'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

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