We help IT Professionals succeed at work.

Remoting unbound comboBox Error

sainavya1215
sainavya1215 asked
on
311 Views
Last Modified: 2010-03-24
Hi,

I have a unbound comboBox which returns dataset via a function to the client and combo is populated with values from database.
The following code works fine on single machine but when tested on remote machine

it throws an error at the last statement in client side code which is


 
            Dim cItem As New cComboItem(dr)

Error "The type system.XML.XMLBoundElement in assembly system.data, Version=1.0.5000.0,culture=Neutral,PublicKeyToken=b77a5c561934e089 is not marked as serializable"



here is the code:

client side
=====
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Obj As New cComboItem
        Dim ds As New DataSet
        ds = Obj.ReturnDataSet()

        Dim dt As DataTable
        dt = ds.Tables(0)

        Dim dr As DataRow
        For Each dr In dt.Rows
            Dim cItem As New cComboItem(dr)  ======ERROR OCCOURS AT THIS POINT============
            CboEmployee.Items.Add(cItem)
        Next




    End Sub

    Private Sub CboEmployee_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CboEmployee.SelectedIndexChanged
        Dim cItem As cComboItem = CType(CboEmployee.SelectedItem, cComboItem)
        MessageBox.Show(cItem.GetId)

    End Sub


DLL
=======================

Imports System.Data.SqlClient
Imports System.Data

''''Commented <serializable()>


Public Class cComboItem

    Public mdr As DataRow
    Public Sub New(ByVal dr As DataRow)
        mdr = dr
    End Sub
    Public Sub New()

    End Sub
    Public Overrides Function ToString() As String
        Return mdr("firstname")
    End Function

    Public Function GetId()
        Return mdr("employeeid")
    End Function


    Public Function ReturnDataSet() As DataSet

        Dim myConnection As SqlClient.SqlConnection
        Dim myDataAdapter As SqlClient.SqlDataAdapter
        Dim myDataSet As DataSet

        myConnection = New SqlConnection("server=(local);database=northwind;Trusted_Connection=SSPI;")


        myDataAdapter = New SqlDataAdapter("SELECT * FROM employees", myConnection)
        myDataSet = New DataSet
        myDataAdapter.Fill(myDataSet, "Employees")
        Return myDataSet

    End Function

End Class
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
hi,
I will try this out and keep u posted within 2 days from now

Thx

Author

Commented:
Thanks it works........sorry for the late reply ....but there is a small prob lets say there at 10 records it displays all the 10 records in comboBox .....works fine
Now if u go and delete some records in sql server and reload the application it still shows 10 records. why is this happening is there any change in code needed?
Since the code simple gets records from the database and returns them to the presentation layer, any change to the underlying data should definately be reflected in the combo box.  A few things come to mind though:

1. It's possible you might be changing the wrong database.  This has happened to me a few times since I'm running several different databases at once.  I know it seems like a silly thing but it's worth looking into...

2. You might have your application configured to do some caching at some level, which might make the application reuse old data rather than query new data.

3.  To find out, modify your cComboItem classes ToString method to look like this:
    Public Overrides Function ToString() As String
        Return mdr("firstname") & "test"
    End Function

This should cause "test" to be added to the end of each name in the combo box.  If "test" appears at the end, then you're probably modifying the wrong data source.  If it doesn't then your front end aspx page must be caching it's output.

Author

Commented:
thanks it works .......

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.