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
try
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)
cmd.Connection.Open()
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 + “)”)
lbField.Items.Add(objreader(0))
lbType.Items.Add(objreader(1))
lbVal.Items.Add(objreader(2))
End While

cmd.Connection.Close()

btnUpdateFact.Text = “Save Facts”
ElseIf (btnUpdateFact.Text = “Save Facts”) Then
btnAdd.Enabled = True
btnUpdateFact.Text = “Update Facts”
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
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