Hi there!
The noobest noob in vb.net strikes back. I have created a form which reads from several SQL Server tables. One of them holds some different document types which are used in the application: invoices, work orders, etc. I can add, modify or delete them from another form. I've created another form with another table where I set the document counters (invoice number and similar stuff). Both work fine. Now I'm working in a third form where I can create new counters for the next year.
Document type:
![Name: Sin nombre1.png
Views: 104
Size: 13.5 KB]()
Doc counter form:
![Name: Sin nombre.png
Views: 96
Size: 24.4 KB]()
Counter creator form:
![Name: Sin nombre2.jpg
Views: 73
Size: 16.8 KB]()
This is what I'm trying to do and this is why I need your help:
I want to create, in the third form, a label for each doc type from the first table. I only get the first row as you can see below "Ejercicio actual" label.
This is my form load code for what I want to do:
I'm not good enough working with collections and "for" statements yet. Your help would be great.
Thanks in advance.
The noobest noob in vb.net strikes back. I have created a form which reads from several SQL Server tables. One of them holds some different document types which are used in the application: invoices, work orders, etc. I can add, modify or delete them from another form. I've created another form with another table where I set the document counters (invoice number and similar stuff). Both work fine. Now I'm working in a third form where I can create new counters for the next year.
Document type:
Doc counter form:
Counter creator form:
This is what I'm trying to do and this is why I need your help:
I want to create, in the third form, a label for each doc type from the first table. I only get the first row as you can see below "Ejercicio actual" label.
This is my form load code for what I want to do:
Code:
Dim conexion As ConnectionStringSettings = _
ConfigurationManager.ConnectionStrings _
("tavos.My.MySettings.tavosConnectionString")
Dim con As New SqlConnection(conexion.ConnectionString)
Dim cmd As New SqlCommand
Dim ird As SqlDataReader
Dim da As SqlDataAdapter
Dim dt As DataTable
Dim dst As DataSet
Public sCodEmp As String
Private bdsTipDoc As Windows.Forms.BindingSource = New BindingSource
Private Sub frm_Contadores_NewContad_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Tipos de documentos existentes
Try
con.Open()
Dim da As New SqlDataAdapter("SELECT * from DOC01", con)
Dim dt As New DataTable
Dim oCB As SqlCommandBuilder = New SqlCommandBuilder(da)
dst = New DataSet
bdsTipDoc.DataSource = dst
da.Fill(dst, "NOMBRE")
''THIS IS THE KEY CODE, I CAN'T MAKE IT WORK PROPERLY
Dim Cl_Nombres As New Collection
For Each Dt_Row As DataRow In dst.Tables(0).Rows
Dim Dt_Nombre As String = Dt_Row.Item("NOMBRE").ToString
Cl_Nombres.Add(CObj(Dt_Nombre))
For Each item As String In Cl_Nombres
Dim lbColTipDoc As New Windows.Forms.Label()
lbColTipDoc.Text = item
With lbColTipDoc
.Location = New Point(30, 50)
End With
pnlEjerciActual.Controls.Add(lbColTipDoc)
Next
Next
End SubThanks in advance.





