[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2012-04-06
4
Medium Priority
?
221 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

649 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