Problem creating an offline cube from a service.

R

roger.camargo

Well, I want to have a background service that creates a Thread.
This thread will create the cube file.

But when I do this. It raises an error.

When I create the Thread not from a service just a program the creation
of the cube file goes well.

I'm really drawing a blank in this....

Please any help would be appreciated.

To reproduce the error. I follow the indications on how to create a
service in the MSDN. and the code is as follow....

/// <summary>
/// Set things in motion so your service can do its work.
/// </summary>
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
System.Threading.Thread mThread = new System.Threading.Thread(new
System.Threading.ThreadStart(RUN));
mThread.IsBackground = true;
mThread.Start();
}

protected void RUN()
{
System.Threading.Thread.Sleep(1000 * 60);

string sConnection=null;
string sLocation=null;
string sSourceDSN=null;
string sCreateCube=@"CREATECUBE=CREATE CUBE cubetest
(
DIMENSION[Place],
LEVEL[All Place] TYPE ALL,
LEVEL[Place Country] ,
LEVEL[Place City] ,
DIMENSION[Product],
LEVEL[All Product] TYPE ALL,
LEVEL[Product Category] ,
LEVEL[Product Name] ,
MEASURE[Quantity] FUNCTION SUM Format '#,#'
)";
string sInsertInto=@"INSERTINTO=INSERT INTO cubetest
(
Place.[Place Country],
Place.[Place City],
Product.[Product Category],
Product.[Product Category],
Measures.[Quantity]
) ";

ADODB.Connection adocon = new ADODB.Connection();


sLocation = @"LOCATION=c:\roger.cub"+"";
sSourceDSN = @"SOURCE_DSN="+"cubetest"+"";

sInsertInto += @"SELECT
c.Country,
c.City,
c.Category,
c.Product,
c.Quantity
FROM
cubetest c
";

sConnection = sLocation + ";" + "\n" + sSourceDSN + ";" + "\n" +
sCreateCube + ";" + "\n" + sInsertInto;

adocon.ConnectionString = sConnection;
adocon.Provider = "MSOLAP";


try
{
adocon.Open(sConnection,"","",0);
WRITELOG("cubo created");
}
catch(Exception e)
{
WRITELOG("Error "+e);
}
}

protected void WRITELOG(string ttt)
{
System.IO.StreamWriter tsw = System.IO.File.AppendText(mfilename);
tsw.WriteLine(ttt);
tsw.Close();
}


and error message is :

System.Runtime.InteropServices.COMException (0x80004005): Cannot
connect to the data source ''.
at ADODB.ConnectionClass.Open(String ConnectionString, String
UserID, String Password, Int32 Options)
at Service_test.Service1.RUN() in c:\documents and settings\roger\my
documents\visual studio projects\service_test\service1.cs:line 168


other error that i found was:

The process cannot access the file c:\roger.cub because it is being
used by another process.

but the file doesn't even exist.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top