Excel Add-In for SAP Business One

Build 20.0.7654

SELECT INTO ステートメント

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

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

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

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

C#

String connectionString = "Url=http://localhost:50000/b1s/v1;User=username;Password=password;CompanyDB=dbname;";

using (SAPBusinessOneConnection connection = new SAPBusinessOneConnection(connectionString)) {
  SAPBusinessOneCommand cmd = new SAPBusinessOneCommand("SELECT DocEntry, DocType INTO [csv://Orders.txt] FROM [Orders] WHERE DocType = 'dDocument_Items' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "Url=http://localhost:50000/b1s/v1;User=username;Password=password;CompanyDB=dbname;" 

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

C#

String connectionString = "Url=http://localhost:50000/b1s/v1;User=username;Password=password;CompanyDB=dbname;";

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

VB.NET

Dim connectionString As [String] = "Url=http://localhost:50000/b1s/v1;User=username;Password=password;CompanyDB=dbname;" 

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

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