Введение в OLAP. Часть 10

Листинг 1

Private Sub Command1_Click()  
Dim cnCube As ADODB.Connection  
Dim s As String  
Dim Prov As String  
Dim DS As String  
Dim SourceDSN As String  
Dim SourceDSNSuffix As String  
Dim CreateCube As String  
Dim InsertInto As String  
Dim Sel As String  
   
 Prov = "PROVIDER=MSOLAP"  
 DS = "DATA SOURCE=d:\nw.cub"  
 SourceDSN = "SOURCE_DSN=""DRIVER=SQL Server;SERVER=MAINDESK;UID=sa;DATABASE=Northwind"""  
 CreateCube = "CREATECUBE=CREATE CUBE Sales( "  
 CreateCube = CreateCube & " DIMENSION [Country], LEVEL [All] TYPE ALL, LEVEL [Country], LEVEL [City], LEVEL [CustomerID],"  
 CreateCube = CreateCube & " DIMENSION [Salesperson], LEVEL [All] TYPE ALL, LEVEL [Salesperson],"  
 CreateCube = CreateCube & " DIMENSION [ShipperName], LEVEL [All] TYPE ALL, LEVEL [ShipperName],"  
 CreateCube = CreateCube & " DIMENSION [CategoryName],LEVEL [All] TYPE ALL, LEVEL [CategoryName], LEVEL [ProductName],"  
 CreateCube = CreateCube & " DIMENSION [OrderDate] TYPE TIME, LEVEL [All] TYPE ALL, LEVEL [Year] TYPE YEAR, LEVEL [Quarter] TYPE QUARTER,  LEVEL [Month] TYPE MONTH,    LEVEL [Day] TYPE DAY,"  
 CreateCube = CreateCube & " MEASURE [Sum Of ExtendedPrice]    FUNCTION SUM,   MEASURE [Sum Of Quantity]    FUNCTION SUM  )"  
   
InsertInto = InsertInto & "InsertInto=INSERT INTO Sales ("  
InsertInto = InsertInto & "[Country].[Country], [City], [CustomerID], [Sum Of ExtendedPrice], [Sum Of Quantity], [ShipperName].[ShipperName], [Salesperson].[Salesperson],"  
InsertInto = InsertInto & "[CategoryName].[CategoryName], [ProductName], [OrderDate]) OPTIONS ATTEMPT_ANALYSIS "  
   
Sel = " SELECT Invoices.Country, Invoices.City, Invoices.CustomerID, Invoices.ExtendedPrice, Invoices.Quantity, Invoices.ShipperName,"  
Sel = Sel + "Invoices.Salesperson, Categories.CategoryName, Products.ProductName, Invoices.OrderDate "  
Sel = Sel + "FROM Northwind.dbo.Categories Categories, Northwind.dbo.Invoices Invoices, Northwind.dbo.Products Products  "  
Sel = Sel + "WHERE Categories.CategoryID = Products.CategoryID AND Invoices.ProductID = Products.ProductID"  
   
InsertInto = InsertInto & Sel  
   
Set cnCube = New ADODB.Connection  
s = Prov & ";" & DS & ";" & SourceDSN & ";" & CreateCube & ";" & InsertInto & ";"  
cnCube.Open s  
   
End Sub  

возврат

Наш канал на Youtube

1999 1 2 3 4 5 6 7 8 9 10 11 12
2000 1 2 3 4 5 6 7 8 9 10 11 12
2001 1 2 3 4 5 6 7 8 9 10 11 12
2002 1 2 3 4 5 6 7 8 9 10 11 12
2003 1 2 3 4 5 6 7 8 9 10 11 12
2004 1 2 3 4 5 6 7 8 9 10 11 12
2005 1 2 3 4 5 6 7 8 9 10 11 12
2006 1 2 3 4 5 6 7 8 9 10 11 12
2007 1 2 3 4 5 6 7 8 9 10 11 12
2008 1 2 3 4 5 6 7 8 9 10 11 12
2009 1 2 3 4 5 6 7 8 9 10 11 12
2010 1 2 3 4 5 6 7 8 9 10 11 12
2011 1 2 3 4 5 6 7 8 9 10 11 12
2012 1 2 3 4 5 6 7 8 9 10 11 12
2013 1 2 3 4 5 6 7 8 9 10 11 12
Популярные статьи
КомпьютерПресс использует