Results 1 to 2 of 2

Thread: datagrid

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    datagrid

    trying to populate a datagrid in a windows form.
    using the clsDataSet to return a dataset as below:

    The function PopulateAuthorsGrid() is called from the windows form i.e. PopulateAuthorsDataGrid

    Can you see why I get this error:
    can't create a child list for field authors.
    The datagrid does not expand, I have to click on the plus sign to expand it.

    Thank you


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    PopulateAuthorsDataGrid()
    End Sub


    'This procedure calls the clsDataSet to return a dataset for the datagrid...
    Private Sub PopulateAuthorsDataGrid()
    Dim oDataset As clsDataSet

    Try
    oDataset = New clsDataSet()

    DataGrid1.DataSource = oDataset.PopulateAuthorsGrid()
    DataGrid1.DataMember = "authorts"

    Catch oEx As Exception
    MessageBox.Show(oEx.Message)
    End Try
    End Sub

    'clsDataSet...
    Public Function PopulateAuthorsGrid() As DataSet

    Dim da As SqlDataAdapter
    Dim ds As DataSet
    Dim oCon As SqlConnection
    Dim strSQL As String

    strSQL = "SELECT au_lname, au_fname, title, price"
    strSQL &= " FROM authors"
    strSQL &= " INNER JOIN titleauthor ON authors.au_id = titleauthor.au_id"
    strSQL &= " INNER JOIN titles ON titleauthor.title_id = titles.title_id"
    strSQL &= " ORDER BY au_lname, au_fname"

    Try
    oCon = New SqlConnection(ConnectToDB)
    da = New SqlDataAdapter(strSQL, oCon)

    ds = New DataSet()
    oCon.Open()
    da.Fill(ds, "authors")
    oCon.Close()
    Catch
    Throw
    End Try

    Return ds
    End Function

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234
    The datagrid does not expand, I have to click on the plus sign to expand it.
    Set datagrid.datasource property to a datatable, not dataset, and then your grid will be without 'plus sign'.

    regard j

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