VB .net, Access Error - specific cast not valid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • amit

    #1

    VB .net, Access Error - specific cast not valid

    Hi guys

    I am trying to use Access Database with VB .net.
    In the stock database I have Fields Code and DrugName; Data Type of
    both is Text.

    In the following code line marked with *** gives the error "specific
    cast not valid "

    The type of both code and drugname is same so logically it should not
    give any error.

    Plz help me...


    ocmEmpresas.Com mandType = CommandType.Tex t
    ocmEmpresas.Com mandText = "Select Code,DrugName from Stock"
    Dim dr As OleDbDataReader
    dr = ocmEmpresas.Exe cuteReader()
    While (dr.Read() = True)
    ListBox1.Items. Add(dr.GetStrin g(0))
    ****ListBox2.It ems.Add(dr.GetS tring(1))****
    End While



    Thanks & Regards
    Amit

  • Peter Proost

    #2
    Re: VB .net, Access Error - specific cast not valid

    Maybe an NULL value in one of the values you want to add

    hope this helps,

    Greetz, Peter

    --
    Programming today is a race between software engineers striving to build
    bigger and better idiot-proof programs, and the Universe trying to produce
    bigger and better idiots. So far, the Universe is winning. (Rich Cook)

    "amit" <amit.muralkar@ gmail.comschree f in bericht
    news:1156850654 .850422.288600@ m73g2000cwd.goo glegroups.com.. .
    Hi guys
    >
    I am trying to use Access Database with VB .net.
    In the stock database I have Fields Code and DrugName; Data Type of
    both is Text.
    >
    In the following code line marked with *** gives the error "specific
    cast not valid "
    >
    The type of both code and drugname is same so logically it should not
    give any error.
    >
    Plz help me...
    >
    >
    ocmEmpresas.Com mandType = CommandType.Tex t
    ocmEmpresas.Com mandText = "Select Code,DrugName from Stock"
    Dim dr As OleDbDataReader
    dr = ocmEmpresas.Exe cuteReader()
    While (dr.Read() = True)
    ListBox1.Items. Add(dr.GetStrin g(0))
    ****ListBox2.It ems.Add(dr.GetS tring(1))****
    End While
    >
    >
    >
    Thanks & Regards
    Amit
    >

    Comment

    • amit

      #3
      Re: VB .net, Access Error - specific cast not valid

      Thanks peter,


      You solved my problem...

      Comment

      Working...