?
Solved

vb.net - create a really long dropdownbox

Posted on 2011-10-12
4
Medium Priority
?
142 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:GlobaLevel
4 Comments
 
LVL 35

Accepted Solution

by:
Norie earned 2000 total points
ID: 36959403
Where/when do you get the error?

By the way, why not use mutiple columns or even dependent/cascading comboboxes?
0
 
LVL 40
ID: 36959478
What is the exact error message? system.row.error means nothing.
0
 
LVL 7

Expert Comment

by:vbigham
ID: 36960401
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36960833
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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Screencast - Getting to Know the Pipeline
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month15 days, 1 hour left to enroll

840 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