Hi, friends, please have a look at this:
I am using AMO, and I do this:
1 step: I drop a column from the source table by SQL:
ALTER TABLE TargetTable Drop COLUMN ColumnName
2 step: I try to update the dsv by AMO:
Dim adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter( _
"SELECT * FROM [dbo].[" + tableName + "] WHERE 1=0", connection)
Dim i As Integer
For i = 0 To dsv.Schema.Tables.Count - 1
If dsv.Schema.Tables(i).TableName = "dbo_" & tableName Then
MessageBox.Show("Before dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
Dim dataTable As DataTable = adapter.FillSchema(dsv.Schema.Tables(i), SchemaType.Mapped)
MessageBox.Show("After dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
End If
Next
But, from the first messagebox and the second messagebox, I see the dsv is not updated after I delete the column.
3 step: I save the dsv to the server.
If Mainform.tDatabase.DataSourceViews.Count > 0 Then
Mainform.tDatabase.DataSourceViews(0).Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull)
End If
Then I check the server, the dsv still include the columnname I have deleted.
Why and how to update the dsv after I delete a column
Thanks!