Avatar of Larry Rungren
Larry Rungren
Flag for United States of America asked on

adding items to list box control from a dataset

in this code the lstall.items.add  generate error

Argument not specified for parameter item??  


          If txtGroup.Text <> "" Then
                lstAllSem.Items.Clear()
                lstSelSem.Items.Clear()
                txtGroup.Text = Replace(txtGroup.Text, "'", "''")
                lstallAdp = New SqlDataAdapter("select * from meet_master where muf_8 = '" & txtGroup.Text & "'", sqlCnn)
                Try
                    lstallAdp.Fill(da)
                Catch ex As Exception
                End Try
                If da.Tables(0).Rows.Count = 0 Then
                    '            MsgBox("No program group available. Selection of other Seminars  not possible.. Continue?", vbYesNo)
                Else
                    Dim dta As DataTable
                    Dim dro As DataRow
                    dta = da.Tables(0)

                    For Each dr0 In dta.Rows

                        lstAllSem.Items.Add = da.Tables(0).Rows(0)("meeting").ToString()
                    Next dr0

                    dta.Dispose()

                End If

            End If

Open in new window



Any help greatly appreciated.
Security.NET ProgrammingVisual Basic.NETMicrosoft SQL ServerVBA

Avatar of undefined
Last Comment
Jacques Bourgeois (James Burger)

8/22/2022 - Mon
Najam Uddin

da.Tables(0).Rows(0).Item("meeting").ToString()
Rgonzo1971

Hi,

pls try

 lstAllSem.Items.Add = dr0.Item("meeting").ToString()

Open in new window


Regards
Fernando Soto

I think this is what you are looking for.
lstAllSem.Items.Add = dr0("meeting").ToString()

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Larry Rungren

ASKER
Thanks for the speedy responses but all three options generate the same error!!
Larry Rungren

ASKER
Dot net certainly has been a major step backwards in the development cycle.  I have found so many things that were done in 3 or 4 lines of code now require 40 -50 lines with all sorts of hidden methods and layered access techniques.  Kinda like going back to proprietary OS's that had massive function libraries that took months if not years to truly master.  Typical MSFT move forward, but cut off the past completely, and the time and expense for the move is ours to swallow, Just my opinion.
ASKER CERTIFIED SOLUTION
Jacques Bourgeois (James Burger)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Larry Rungren

ASKER
Jacques Bourgeois (James Burger)

Sorry if I seem negative.. First major conversion and what was second nature,  16 years VB4-6, is seemingly a different universe with no real easy path upward.  Documentation is sketchy at best and most  sample processes I can find seem to relate to gridview options.  A true desktop, data entry process sample seems to be lacking.  I've made great headway, and the only hangup is connecting existing Crystal Reports 2011 report to vb2010 without rewriting them.  I have 14 reports in this app that ran fine under VB6, but that is for another day.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Larry Rungren

ASKER
Thanks for the help and the smack back to reality.
Jacques Bourgeois (James Burger)

I understand your frustrations. I went through them too at the beginning of the century, having used VB from VB2 to VB6, and training other programmers from VB3 to VB6.

But keep with it. VB.NET is a far better environment and language than VB6 was. There might be a few things that take a few lines of code more than before. But they are a small fee for what usually ends up as more performance and security (although security is often frustating in .NET). And expect to write a lot less code. In the 10,000+ classes of the framework, there is almost always a method somewhere that will do what you want to do. You just need to take the time to look for it.

It took me 60 lines of codes in VB6 to retrieve the format of the date, as set in the Control Panel, in a bilingual environment. Around 20 for the number format. It takes only 1 line for each once you have discovered the System.Globalization namespace. Try to get the date a file was created or last opened without being written to in VB6. A one line thing again in .NET.

You might find that working with database involves a little more, and it does, but not much once you get your ways with the System.Data namespace. Up to 2 years ago, I was still stuck with unfrequent maintenance with old VBA code in Microsoft Access, and I missed ADO.NET almost everytime I had to go back to Recordsets. Start doing web or mobile development, and you will understand and appreciate even more the new ways of doing database stuff, and that you do not have to learn new techniques. ADO.NET is the same way no matter the type of application.

Get used to the documentation too. It is a lot better than it was in VB6. It's just that it is so huge that it takes a while before you grab the proper ways to use it. Install the local help that is not installed by default and use it as your first source instead of online help. Local help can be adapted to what you do. If you do not do Web development, do not install the web modules and they won't show up when you search. And the local help has an Index, something that is really lacking with online help, where the only way to go is through search. When you need to search outside of the tools that Visual Studio link you with, use Bing instead of Google. Bing being a Microsoft thing, they have a tendency to emphasize their own products. I find that you usually find information about Microsoft tools and apllications more easily on Bing than when you go through Google, that makes its money by throwing in stuff for companies that paid to get moved up the result of a search.

As for Crystal Report, well... it's Crystal Report. Don't blame .NET. Blame the 101 companies who worked on Crystal Report since it's inception, and who have never completely nailed it. And still don't, even if .NET has been officially around for more than 13 years.