使用 Siebel 在商務元件上執行 SELECT 查詢
本節示範如何使用 .NET Framework Data Provider for Siebel eBusiness Applications,從 Siebel 商務元件中選取資料。
從 Siebel 商務元件選取資料
本節示範如何從 Siebel 存放庫中的「帳戶」商務元件選取資料。
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using Microsoft.Adapters.SiebelDbProvider;
namespace SiebelADO
{
class Program
{
static void Main(string[] args)
{
try
{
SiebelProviderFactory factory = SiebelProviderFactory.Instance;
DbConnection connection = factory.CreateConnection();
connection.ConnectionString = "Username=SADMIN;Password=SADMIN;ServiceUri=172.23.115.223:2321;SiebelObjectManager=SSEObjMgr;SiebelEnterpriseServer=ent771;Language=enu;SiebelRepository=Siebel Repository";
connection.Open();
DbCommand command = connection.CreateCommand();
//Here is a list of sample commands. The second command shows how the Siebel ViewMode can be specified in the query.
//command.CommandText = "SELECT * from Account.Account where [Name] LIKE '3Com'";
//command.CommandText = "Select [Name] from [Account].[Account] where [Name] LIKE '3Com' OPTION ‘ViewMode 1’";
command.CommandText = "SELECT [Name], [Postal Code], Id From Account.Account where [Postal Code] != '60626' Order BY Id ASC, Name DESC";
DbDataReader dbReader = command.ExecuteReader();
while (dbReader.Read())
{
for (int i = 0; i < dbReader.FieldCount; i++)
{
string name = dbReader.GetName(i);
string val = dbReader[i].ToString();
Console.WriteLine(name + "\t:" + val);
Console.WriteLine("=========================");
}
}
Console.WriteLine("Press any key...");
Console.ReadLine();
}
catch (Exception exp) { Console.WriteLine(exp.Message); }
}
}
}
另請參閱
使用 .NET Framework Data Provider for Siebel eBusiness 應用程式
使用 Siebel 在商務服務上執行 EXECUTE 作業