locked
Get SqlCeResultSet from BindingSource RRS feed

  • Question

  • I have set the DataSource of a BindingSource to a SqlCeResultSet from the designer.

    When my applicaton runs I want to cast the DataSource back to SqlCeResultSet so that I can search for a specified record. However the cast fails because the type of Datasource is Runtime.

    Is there any way to do it?

    Thanks

    Thursday, June 9, 2011 1:37 PM

Answers

  • Hi Aristeidis,

     

    I think you need to use SQL command to select the records which you want, and execute it when you call it.

     

    Please see the sample in SqlCeResultSet Class

    You need to change this line:

     cmd.CommandText = "SELECT * FROM myTable"; to "SELECT * FROM /*yourtablename*/ WHERE name=***"

     

    You can through this link to get more information about SQL Command grammar.

    SELECT - SQL Command

     

    I hope my suggestions can help you to solve this problem.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, June 14, 2011 8:18 AM

All replies

  • You should be able to use BindingSource.DataSource property to get actual data source.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, June 9, 2011 3:52 PM
  • How can I search for a record from the BindingSource.DataSource property?
    Thursday, June 9, 2011 5:36 PM
  • I'm not sure I understand your question.

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, June 9, 2011 8:56 PM
  • Since the data source of the binding source is a SqlCeResultSet, is it possible to search through the results of the SqlCeResultSet and find a specific record that matches some criteria?

    For example, the SqlCeResultSet returns all customers from a db and I want to find a customer with a given name.


    Friday, June 10, 2011 6:27 AM
  • Hi Aristeidis,

     

    I think you need to use SQL command to select the records which you want, and execute it when you call it.

     

    Please see the sample in SqlCeResultSet Class

    You need to change this line:

     cmd.CommandText = "SELECT * FROM myTable"; to "SELECT * FROM /*yourtablename*/ WHERE name=***"

     

    You can through this link to get more information about SQL Command grammar.

    SELECT - SQL Command

     

    I hope my suggestions can help you to solve this problem.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, June 14, 2011 8:18 AM