Link to home
Start Free TrialLog in
Avatar of Larry Rungren
Larry RungrenFlag 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
                txtGroup.Text = Replace(txtGroup.Text, "'", "''")
                lstallAdp = New SqlDataAdapter("select * from meet_master where muf_8 = '" & txtGroup.Text & "'", sqlCnn)
                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)
                    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


                End If

            End If

Open in new window

Any help greatly appreciated.
Avatar of Najam Uddin
Najam Uddin
Flag of United States of America image

Avatar of Rgonzo1971


pls try

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

Open in new window

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

Open in new window

Avatar of Larry Rungren


Thanks for the speedy responses but all three options generate the same error!!
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.
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Thanks for the help and the smack back to reality.
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.