Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

Creating Datasource View programmatically using AMO

$
0
0

I have created the following objects using AMO. My Primary target is to make connection with a Oracle Database and I'm using Oracle Client for it .

1. Datasource 

2.Data Source View

3.Cube

4.MeasureGroups etc;

For verifying that the objects are created from my Script I'm using BIDS . It went well . But If I'm trying to use the "Explore Data" command,

But It's popping this error,

The Connection String that I'm using is , 

private string oraconString = @"Provider=OraOLEDB.Oracle.1;Data Source=//cmbtrndb02/hector;User ID=trnint16;Password=trnint16;Intergrated Security=false";

I have used the Impersonation Info methods as well (In CreateDatabase(), CreateDataSource() but nothing has changed )

Impersonation codes as follows , 

static Database CreateDatabase(Server svr, String DatabaseName)
        {
            Database db = null;
            if ((svr!=null)&&(svr.Connected))
            {
                //Drop the database if it already exists
                db = svr.Databases.FindByName(DatabaseName);
                if (db!=null)
                {
                    db.Drop();
                }

                //Create the Database

                db = svr.Databases.Add(DatabaseName);
                
                db.DataSourceImpersonationInfo = new ImpersonationInfo(ImpersonationMode.ImpersonateServiceAccount, "trnint16", "trnint16");
                db.Update();
            }

            return db;
                           
        }

 static string CreateDataSource(Database db, string strDataSourceName, string strConnectionString)
        {
            Server svr = db.Parent;
            DataSource ds = db.DataSources.FindByName(strDataSourceName);
            if (ds!=null)
                ds.Drop();
            //Create the DataSource

                ds = db.DataSources.Add(strDataSourceName, strDataSourceName);
                
                ds.ConnectionString = strConnectionString;
                ImpersonationInfo im = new ImpersonationInfo(ImpersonationMode.ImpersonateServiceAccount, "trnint16", "trnint16");
                ds.ImpersonationInfo = im;

                

                

                // Send the data source definition to the server 

                ds.Update();

                return ds.Name;
            
        }

Please give me a light !


Viewing all articles
Browse latest Browse all 14337