Results 1 to 8 of 8

Thread: complex databind question

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    7

    complex databind question

    I am getting this error and I dont know why.
    An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll
    Additional information: Cannot create a child list for field ?????.
    --------------------------------------------------------------------------------

    Thanks in advance for any help.
    this is my code:


    Code:
    varAccountID = lblAccountID.Text
            'fills demos dataset        
            Dim selectCMD As SqlCommand = New SqlCommand("SELECT q.question_id, q.short_form, '' FROM question AS q INNER JOIN question_set AS qs ON q.question_id=qs.question_id WHERE qs.affinity_id=1 AND q.question_id NOT IN (SELECT v.question_id FROM answer_heading AS h INNER JOIN answer_value AS v ON h.answer_id=v.answer_id WHERE h.account_id = '" & varAccountID & "')UNION SELECT q.question_id, q.short_form, v.response FROM answer_heading AS h INNER JOIN answer_value AS v ON h.answer_id=v.answer_id INNER JOIN question AS q ON v.question_id=q.question_id WHERE(h.account_id = '" & varAccountID & "')ORDER BY q.question_id", SqlConnection1)
    
            Dim daAnswers As SqlDataAdapter = New SqlDataAdapter
            daAnswers.SelectCommand = selectCMD
    
            SqlConnection1.Open()
    
            Dim DsAnswers1 As DataSet = New DataSet
            DataGrid1.DataSource = DsAnswers1
    
            DsAnswers1.Clear()
            daAnswers.Fill(DsAnswers1)
    
            SqlConnection1.Close()
    Last edited by bprego; Feb 11th, 2004 at 03:01 PM.

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    The help file has an example like this:

    Code:
    Private Sub BindToDataSet(myGrid As DataGrid)
        ' Create a DataSet.
        Dim myDataSet As New DataSet("myDataSet")
        ' Insert code to populate DataSet with several tables.
        myGrid.DataSource = myDataSet
        ' Use the DataMember property to specify the DataTable.
        myGrid.DataMember = "Suppliers"
    End Sub 'BindToDataSet

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    7

    how do I make datagrid have two memebers

    how will having two datasets allow me to pull data from both datasets into the grid when you can only have one DataMemeber

    Code:
    myGrid.DataMember = "Suppliers"
    if you can show me how to pull the questionID and the shortform from A question dataset and the response from A Answer dataset into the datagrid than I can use what you are suggesting.

    or can I create two datasets, then put those datasets together in a third? How would I do that?

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    You can do a join query on data to merge two tables (using your question ID). Its quite a common feature of databases.

    In fact, looking at your command code, you have already linked them together, so there will only be one datatable in the dataset.

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    7

    I have tried all the tables used in my query

    DataGrid1.DataMember = "?????"

    I have tried to replace ????? with

    question
    answer_value
    answer_heading
    question_set

    and i get the same error

    An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
    Additional information: Cannot create a child list for field ?????.
    So what do I replace the ????? with?

    The query as it stands above is the way it has to be. I have to use the union.

    Thanks

  6. #6
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    The data returned IS the table name, but you may not have it named (ive not tried it tbh). The ????? is the name of the table for the grid to load, you have been trying a field. Look at giving the return table/data a name.

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    7

    anyone else have an idea

    the advice I have been given so far is not working. thanks for your help grim but I think your missing the whole picture.

  8. #8
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Your possibly right .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width