Hi Jasmine,
1) Indeed, you have to use dsoServer.Connect "CUTIEDEVIL";
2) I assume you use Angoss' controls - apparently your code is correct,
check their documentation/samples;
3) My guess (without seeing your "Foodmart 2000" database) is that
dsoDB.DataSources("FoodMart") returns null. One common reason is that you
might not have a datasource called "FoodMart", maybe its name is different.
--
Raymond Balint [MS]
This posting is provided "AS IS" with no warranties, and confers no rights.
[quoted text, click to view] "Jasmine" <siokping88@hotmail.com> wrote in message
news:000c01c37f1d$0ed82010$a001280a@phx.gbl...
> My question is kinda long. Thanks for your patient. =)
>
> 1. I am using the OLEDB-DM-Doc.vbp to modify the customer
> segmentation of FoodMart 2000. I open the OLEDB-DM-
> Doc.vbp, and added the Microsoft Decision Support Object
> from the references. Other things such as decision tree
> code and liftchart is ignored, except the ViewSegViewer.
> After that, I created a button in Form1 and named it as
> Connect. When the button is clicked, I called the public
> sub CreateRelMiningModel(). I pasted the following code
> under public sub CreateRelMiningModel ()
>
> PS: my server name in Analysis Manager is called
> CUTIEDEVIL. So I have to change the dsoserver.connect
> to "CUTIEDEVIL", is it correct?
>
> Public Sub CreateRelMiningModel()
> Dim dsoServer As New DSO.Server
> Dim dsoDB As DSO.MDStore
> Dim dsoDS As DSO.DataSource
> Dim dsoDMM As DSO.MiningModel
> Dim dsoColumn As DSO.Column
> Dim dsoRole As DSO.Role
>
> Dim strLQuote As String, strRQuote As String
> Dim strFromClause As String
>
> ' Constants used for DataType property
> ' of the DSO.Column object.
> ' Note that these constants are identical to
> ' those used in ADO in the DataTypeEnum enumeration.
> Const adInteger = 3
> Const adWChar = 130
>
> ' Connect to the server on this computer.
> dsoServer.Connect "CUTIEDEVIL"
>
> ' Select the FoodMart 2000 database.
> Set dsoDB = dsoServer.MDStores("FoodMart 2000")
>
> ' Retrieve the open and close quote characters for
> ' the FoodMart data source.
> strLQuote = dsoDB.DataSources("FoodMart").OpenQuoteChar
> strRQuote = dsoDB.DataSources("FoodMart").CloseQuoteChar
>
> ' The Customer table is the fact table for this
> ' relational data mining model; this variable will
> ' make it easier to understand the code that
> ' follows.
> strFromClause = strLQuote & "customer" & strRQuote
>
> ' Check for the existence of the model on this computer.
> If Not dsoDB.MiningModels("CustSalesModelRel") Is
> Nothing Then
> ' If this model exists, delete it.
> dsoDB.MiningModels.Remove "CustSalesModelRel"
> End If
>
> ' Create a new relational mining model
> ' called CustSalesModelRel.
> Set dsoDMM = dsoDB.MiningModels.AddNew
> ("CustSalesModelRel", _
> sbclsRelational)
>
> ' Create a new mining model role called All Users
> Set dsoRole = dsoDMM.Roles.AddNew("All Users")
>
> ' Set the needed properties for the new mining model.
> With dsoDMM
> .DataSources.AddNew "FoodMart", sbclsRegular
> ' Set the description of the model.
> .Description = "Analyzes the salaries " & _
> "of customers"
> ' Set the case table for the model to the
> ' Customer table.
> .FromClause = strFromClause
> ' Select the algorithm provider for the model.
> .MiningAlgorithm = "Microsoft_Clustering"
> ' Let DSO define the training query.
> .TrainingQuery = ""
> ' Save the existing structure.
> .Update
> End With
>
> ' Create the columns pertinent to the new model.
>
> ' Create the CustomerID column as a key column.
> Set dsoColumn = dsoDMM.Columns.AddNew("CustomerID", _
> sbclsRegular)
> ' Set the column properties for the new column.
> With dsoColumn
> ' Set the source field from the case table for
> ' the column.
> .SourceColumn = strFromClause & "." & strLQuote & _
> "customer_id" & strRQuote
> .DataType = adInteger
> .IsKey = True
> .IsDisabled = False
> End With
>
> ' Create the Gender column as an attribute column.
> Set dsoColumn = dsoDMM.Columns.AddNew("Gender", _
> sbclsRegular)
> With dsoColumn
> .ContentType = "DISCRETE"
> .SourceColumn = strFromClause & "." & strLQuote & _
> "gender" & strRQuote
> .DataType = adWChar
> .IsDisabled = False
> End With
>
> ' Create the Marital Status column as an attribute
> column.
> Set dsoColumn = dsoDMM.Columns.AddNew("Marital Status",
> _
> sbclsRegular)
> With dsoColumn
> .ContentType = "DISCRETE"
> .SourceColumn = strFromClause & "." & strLQuote & _
> "marital_status" & strRQuote
> .DataType = adWChar
> .IsDisabled = False
> End With
>
> ' Create the Education column as an attribute column.
> Set dsoColumn = dsoDMM.Columns.AddNew("Education", _
> sbclsRegular)
> With dsoColumn
> .ContentType = "DISCRETE"
> .SourceColumn = strFromClause & "." & strLQuote & _
> "education" & strRQuote
> .DataType = adWChar
> .IsDisabled = False
> End With
>
> ' Create the Yearly Income column as an predictable
> column.
> Set dsoColumn = dsoDMM.Columns.AddNew("Yearly Income", _
> sbclsRegular)
> With dsoColumn
> .ContentType = "DISCRETE"
> .SourceColumn = strFromClause & "." & strLQuote & _
> "yearly_income" & strRQuote
> .DataType = adWChar
> .IsInput = False
> .IsPredictable = True
> .IsDisabled = False
> End With
>
> ' Save the data mining model.
> With dsoDMM
> ' Set the LastUpdated property of the new mining
> model
> ' to the present date and time.
> .LastUpdated = Now
> ' Save the model definition.
> .Update
> End With
>
> ' Process the data mining model.
> With dsoDMM
> ' Lock the mining model for processing
> .LockObject olapLockProcess, _
> "Processing the data mining model in sample code"
> ' Fully process the new mining model.
> ' This may take up to several minutes.
> .Process processFull
> ' Unlock the model after processing is complete.
> .UnlockObject
> End With
>
> ' Clean up objects and close server connection
> Set dsoRole = Nothing
> Set dsoColumn = Nothing
> Set dsoDMM = Nothing
>
> dsoServer.CloseServer
> Set dsoServer = Nothing
>
> End Sub
>
>
> 2. A button called View Cluster is created too. When this
> button is clicked, the ViewSegViewer() function is called.
> I only change the Mining Model name from ClusterModel to
> CustSalesModelRel. Is it ok?
>
Hi, Dear Raymond Balint
I have solved the problem that i posted and a mining model
is successfully created. My MDStores name is Tutorial and
the Data Source Name is Tutorial too. Finally... However,
I am facing another problem, that is cannot display the
result...
I am using the angoss OLEDB-DM-Doc.vbp sample. In the
code, a clusterConnection is already declared as new
ADODB.Connection in th Option Explicit. This
clusterConnection is then trained in the
DataConnectionWork function. After that, it is used in the
following function.
Function ViewSegViewer()
SegViewerCtrl2.InitFromOLEDBDM
clusterConnection, "CustSalesModelRel"
SegViewerCtrl2.PlotData
End Function
But as the code that i posted before, i didn't use the
code in the DataConnection function, but i changed to the
Public Sub CreateRelMiningModel().
If not mistaken, the ClusterConnection is the training
query, rite? But in my CreateRelMiningModel function, the
training query is defined by the dso, isn't it? when i try
to run it, an error occur saying
that "Method 'InitFromOLEDBDM' of object 'ISegViewerCtrl'
failed". How to fix this problem?
With dsoDMM
.DataSources.AddNew "FoodMart", sbclsRegular
' Set the description of the model.
.Description = "Analyzes the salaries " & _
"of customers"
' Set the case table for the model to the
' Customer table.
.FromClause = strFromClause
' Select the algorithm provider for the model.
.MiningAlgorithm = "Microsoft_Clustering"
' Let DSO define the training query.
.TrainingQuery = ""
' Save the existing structure.
.Update
End With
How can i modify it? The provider that i am using is
Microsoft OLEDB Provider for ODBC Drivers, will it effect?
2. If i want to use the DataConnectionWork function in the
and discard my Public sub CreateRelMiningModel(), how do i
modify the code? I only want to use Segmentation only. I
really need the complete code for the DataConnectionWork
and ClusterConnection part, i am really confused with the
Clusterconnection provider, DataFile Name,
ClusterConnection ConnectionString, and the two execute
command. The second execute command(Insert into...), the
Angoss example specify the provide to Microsoft.Jet.OLEDB
4. I really confused with all this...
3. Dear Mr Raymond Balint, is it possible for me to have a
chat session with sir in order to clear all my doubts. I
really need your guideline and help urgently. It would not
be a long session. Please reply me as soon as possible.