?
Solved

How to assign the value to combobox when field is of int type.

Posted on 2012-04-06
4
Medium Priority
?
214 Views
Last Modified: 2012-05-08
s = "select distinct id from mststudents where deoflag=0 order by id"
        da = New SqlDataAdapter(s, con)
        dt = New DataTable()
        da.Fill(dt)

        Dim newCustomersRow As DataRow = dt.NewRow()

        newCustomersRow("id") = "--Select TID--"
        dt.Rows.InsertAt(newCustomersRow, 0)

        With cmbtid

            .DisplayMember = "id"
            .ValueMember = "id"
            .DataSource = dt
        End With
        cmbtid.Refresh()



//error comes is Input string was not in a correct format.Couldn't store <--Select TID--> in id Column.  Expected type is Int64.
0
Comment
Question by:searchsanjaysharma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1500 total points
ID: 37815829
you can have your select query return 2 values: an int and a string:

s = "select distinct id, cast(id as varchar) as IDString from mststudents where deoflag=0 order by id"

when you add your dummy value:

        newCustomersRow("IDString") = "--Select TID--"
        newCustomersRow("id") = "0"

and when you set your combo:

            .DisplayMember = "IDString"
0
 

Author Comment

by:searchsanjaysharma
ID: 37885193
ok
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 37885550
is it working? if your question is fully answered, you now need to close it by accepting one of the comments.
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37945388
ok
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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