Update Fact tables for Data Warehouse in VB.Net

Private Sub btnUpdateFact_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateFact.Click
Dim sqlupdatetable As String
Dim counter As Integer
counter = 0
If (btnUpdateFact.Text = “Update Facts”) Then

btnAddFact.Enabled = False

If (cbFTableName.SelectedIndex = -1) Then
MessageBox.Show(“Please select a Table Name to update”, “Information”, MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
cmd.Connection = New System.Data.SqlClient.SqlConnection(ConnectionString)
sqlupdatetable = “Select syscolumns.name, systypes.name, syscolumns.length from syscolumns, SysObjects, systypes where((Sysobjects.name = ‘” & cbFTableName.SelectedItem.ToString & “‘) and (Sysobjects.xtype = ‘U’) and (sysobjects.xtype not like ‘PK’) and (Sysobjects.id = syscolumns.id) and (systypes.xtype = syscolumns.xtype)) order by syscolumns.colorder”

cmd = New System.Data.SqlClient.SqlCommand(sqlupdatetable, cmd.Connection)

objreader = cmd.ExecuteReader

While objreader.Read
lbFFields.Items.Add(objreader(0) + ” ” + objreader(1) + ” (” + objreader(2).ToString + “)”)
End While


btnUpdateFact.Text = “Save Facts”
ElseIf (btnUpdateFact.Text = “Save Facts”) Then
btnAdd.Enabled = True
btnUpdateFact.Text = “Update Facts”
End If
Catch ex As Exception
End Try
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s