vb.net - create a really long dropdownbox

id rather use autocomplete...but that a little more involved for now...so 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.


Try

                    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

                        Tbl.Clear()
                        Try

                            TblAdaptar.Fill(Tbl)
                            MyDropDown.DataSource = Tbl
                            MyDropDown.DataBind()

                        Catch ex As Exception
                        End Try

                    End Using

                Catch ex As Exception

                End Try

Open in new window

LVL 10
GlobaLevelProgrammerAsked:
Who is Participating?
 
NorieVBA ExpertCommented:
Where/when do you get the error?

By the way, why not use mutiple columns or even dependent/cascading comboboxes?
0
 
Jacques Bourgeois (James Burger)PresidentCommented:
What is the exact error message? system.row.error means nothing.
0
 
vbighamCommented:
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?



0
 
CodeCruiserCommented:
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!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.