Performing a SELECT Query on Business Components

This section demonstrates how to select data from a Siebel business component using the .NET Framework Data Provider for Siebel eBusiness Applications.

Selecting Data from a Siebel Business Component

This section demonstrates how to select data from the "Account" business component in the Siebel repository.

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); }
       }
    }
}
See Also

Concepts

Using the .NET Framework Data Provider for Siebel eBusiness Applications
Performing an EXECUTE Operation on Business Services

Page view tracker