I am building an application to build and process cubes using DSO.
I have not been able to set the Data Source to a newly created cube.

Here's the piece of code I am using:

Public Function BuildNewCube(DBName,CubeName,RID)
Set dsoDB = dsoServer.MDStores(DBName)
If Not dsoDB.MDStores.Find(CubeName) Then
Set dsoCube = dsoDB.MDStores.AddNew(CubeName)
Set dsoDS = dsoDB.DataSources(4)
BuildNewCube = 1
BuildNewCube = 0
End If
End Function

Does anybody have an idea why is this happening? No error is being returned when executing this function.