farshad Posted July 19, 2003 Posted July 19, 2003 (edited) 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 Edited July 20, 2003 by Robby Quote Farshad
Moderators Robby Posted July 20, 2003 Moderators Posted July 20, 2003 Is this a typo ... DataGrid1.DataMember = "authorts" Quote Visit...Bassic Software
farshad Posted July 20, 2003 Author Posted July 20, 2003 silly me. That was the problem. It now works fine. Thanks for your time.:-) Quote Farshad
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.