Im new to .NET and I am having probs with this
Every time I reload the form the same data is repeated again....
Done reading on msdn and another forum
cant figure out why the DsProds.Tables( 0).Clear() is not
clearing the first lot of data ?
Any I mean any help or suggestion welcome 2 days and this has done my head in lol!!!
Every time I reload the form the same data is repeated again....
Done reading on msdn and another forum
cant figure out why the DsProds.Tables( 0).Clear() is not
clearing the first lot of data ?
Code:
' This is in my load event
Dim DsProds As New DataSet
Dim DsProdsTable As New DataTable("Products")
DsProds.Tables.Add(DsProdsTable)
DsProds.Tables(0).Clear()
'DataAdapter fill DataSet
Dim connectionString As String = _
My.Settings.StaticCartSQLConnectionString
Dim connection As SqlConnection = _
New SqlConnection(connectionString)
connection.Open()
Dim command As SqlCommand = _
New SqlCommand("SELECT * FROM Products", connection)
Dim ProdsAdapter As SqlDataAdapter = New SqlDataAdapter(command)
ProdsAdapter.Fill(DsProds)
TextBox1.Text = DsProds.Tables.Count()
Dim NewRow As DataRow
For Each NewRow In DsProds.Tables(0).Rows
' to add as string to the names of controls
Dim ProdID
ProdID = NewRow.Item("Prod_ID").ToString
'
'ProdLabel
'
Const ProdLabel_HEIGHT As Integer = 13
Const ProdLabel_WIDTH As Integer = 39
Dim ProdLabel As New Label
ProdLabel.Anchor = System.Windows.Forms.AnchorStyles.None
ProdLabel.AutoSize = True
ProdLabel.Location = New Point(ProdLabelcontrolLocation.X, ProdLabelcontrolLocation.Y)
ProdLabel.Name = "ProdLabel," + ProdID
ProdLabel.Height = ProdLabel_HEIGHT
ProdLabel.Width = ProdLabel_WIDTH
ProdLabel.Text = NewRow.Item("Prod_Desc")
'Add the label to the controls collection.
Controls.Add(ProdLabel)
' Increment the LocationY so the next control won't overwrite it.
ProdLabelcontrolLocation.Y += ProdLabel.Height + 1
'
'more controls
'more controls
'Cut the controls code down as that is not the issue
Next
Comment