Cast conversion exception occurred RRS feed

  • Question

  • hello ,

    i am using LINQ TO SQL and my Project Saving data of employee

    and whern i Delete or search the saved data then it shows a cast convertion exception

    i search or delete the data of employees by filling the name of employee.


    following is the code for my delete button click event




                If namecombo.Text = "" Then
                    MessageBox.Show("Select the name to delete")
                End If

                Dim db As New dbcontext
                Dim data = From tmp In db.tblbasic_infos Where tmp.ename = namecombo.Text Select tmp

                MessageBox.Show("Employee is deleted Successfully")
            Catch ex As Exception

            End Try



    what is this cast convertion exception

    it does not occured all time for all names but occurss for certain names like it works when i fill "karan" {it may be any other, in my checking i fill this} it gives exception but when i fill 

    "taranjeet kaur" then it executes linq query and then again i fill "karan" then it executes .

    whats the problem with this........



    THE exception is:

    unable to cast object of type ''1[windowsapplication1.tblbasic_info]'to type 'windowsapplication1.tblbasic_info'.


    Tuesday, April 13, 2010 10:15 AM