Solved - create a really long dropdownbox

Posted on 2011-10-12
Last Modified: 2012-05-12
id rather use autocomplete...but that a little more involved for I am tyring to get the values to concatenate into a long field and populate a dropdown list...however it gives me an error...

any ideas whi I get the error..system.row.error.


                    Dim MyDropDown As DropDownList
                    Dim TC_ID As String
                    Dim sqlConnection As String
                    TC_ID = Session("SessionTC_ID")
                    MyDropDown = DropDownList1

                    Using sqlConn As New SqlConnection
                        sqlConnection = "Data Source=xx.xx.xx.xx;Initial Catalog=xx;Persist Security Info=True;User ID=xx;Password=xx"
                        sqlConn.ConnectionString = sqlConnection
                        Dim SQLString As String = "SELECT '[' + LEFT(cast(name as nvarchar(max)),30) + '] [' + LEFT(cast(city as nvarchar(max)),20) + '] [' + LEFT(cast(shoe as nvarchar(max)),20) + '] [' + LEFT(cast(shoexxx as nvarchar(max)),20) + ']' " & _
                         "FROM  customer " & _
                         "WHERE name like '%" & Session("var_search_box") & "%'" & _
                         "and  Type <> 'Manufacturer' " & _
                         "ORDER BY Name ASC "

                        Dim TblAdaptar As New SqlDataAdapter(SQLstring, sqlConn)
                        Dim Tbl As New DataSet


                            MyDropDown.DataSource = Tbl

                        Catch ex As Exception
                        End Try

                    End Using

                Catch ex As Exception

                End Try

Open in new window

Question by:GlobaLevel
    LVL 33

    Accepted Solution

    Where/when do you get the error?

    By the way, why not use mutiple columns or even dependent/cascading comboboxes?
    LVL 40

    Expert Comment

    by:Jacques Bourgeois (James Burger)
    What is the exact error message? system.row.error means nothing.
    LVL 7

    Expert Comment

    Well, obviously it means SOMETHING not nothing..

    Either the SQL statement is not able to execute, or the data adapter is having trouble filling it..  Those are just my initial guesses.  Mostly because the SQL statement does seem a little bit strange (are there some missing commas?).  Instead of doing nothing in the catch blocks can you try System.Diagnostics.Debug.WriteLine(ex) and post the results?  Also, if you can step through the code with the debugger and let us know which line it fails on that would be awesome.

    I'm not sure of the limitations of databinding with winforms, but can it really be that large?  It might be.. Please advise on a typical result set.

    Do you have a way to check that the SQL statement does in fact return the values?  I mean if you use the literal output of "SQLString" as it happens at runtime, do you get the desired results?

    LVL 83

    Expert Comment

    Are you sure the values are as long as you are expecting them?

    >LEFT(cast(city as nvarchar(max)),20)

    Is city always more than 20 characters? Casting it to varchar(max) wont pad it!

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video discusses moving either the default database or any database to a new volume.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now