Problems displaying data on 3 datagrids

diverdan

Active member
Joined
Jan 2, 2006
Messages
34
Location
London UK
Programming Experience
Beginner
Hi there,

I have managed to find a piece of code that allows me to display 3 datagrids. It works ok when using the northwind example but when I try using my own database I can only display 2 out of the 3 datagrids.

For testing purposes I have used the same table for all 3 grids.

Has anyone had this problem?

This is my code.
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] frmCustomers_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].WindowState = FormWindowState.Maximized
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] conn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlClient.SqlConnection([/SIZE][SIZE=2][COLOR=#800000]"Server = "[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#800000]"nx6130"[/COLOR][/SIZE][SIZE=2] & _
[/SIZE][SIZE=2][COLOR=#800000]"; Database = ActionGlass; "[/COLOR][/SIZE][SIZE=2] & _
[/SIZE][SIZE=2][COLOR=#800000]"Integrated Security = sspi;"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ds [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] daOrders [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlClient.SqlDataAdapter([/SIZE][SIZE=2][COLOR=#800000]"Select * from tblQuotes"[/COLOR][/SIZE][SIZE=2], conn)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] daQuotes [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlClient.SqlDataAdapter([/SIZE][SIZE=2][COLOR=#800000]"Select * from tblQuotes"[/COLOR][/SIZE][SIZE=2], conn)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] daPayments [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlClient.SqlDataAdapter([/SIZE][SIZE=2][COLOR=#800000]"Select * from tblQuotes"[/COLOR][/SIZE][SIZE=2], conn)
daOrders.Fill(ds, [/SIZE][SIZE=2][COLOR=#800000]"tblQuotes"[/COLOR][/SIZE][SIZE=2])
daQuotes.Fill(ds, [/SIZE][SIZE=2][COLOR=#800000]"tblQuotes"[/COLOR][/SIZE][SIZE=2])
daPayments.Fill(ds, [/SIZE][SIZE=2][COLOR=#800000]"tblQuotes"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#008000]'ds.Relations.Add("EmployeeOrder", ds.Tables("Employees").Columns("EmployeeID"), _
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' ds.Tables("Orders").Columns("EmployeeID"))
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'ds.Relations.Add("Order2Details", ds.Tables("Orders").Columns("OrderID"), _
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' ds.Tables("OrderDetails").Columns("OrderID"))
[/COLOR][/SIZE][SIZE=2]grdInvoices.ReadOnly = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2]grdQuotes.ReadOnly = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2]grdPayments.ReadOnly = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'grdInvoices.AllowUserToAddRows = False
[/COLOR][/SIZE][SIZE=2]grdInvoices.DataSource = ds
grdQuotes.DataSource = ds
grdPayments.DataSource = ds
grdInvoices.DataMember = [/SIZE][SIZE=2][COLOR=#800000]"tblQuotes"
[/COLOR][/SIZE][SIZE=2]grdQuotes.DataMember = [/SIZE][SIZE=2][COLOR=#800000]"tblQuotes"
[/COLOR][/SIZE][SIZE=2]grdPayments.DataMember = [/SIZE][SIZE=2][COLOR=#800000]"tblQuotes"[/COLOR][/SIZE]

Any help would be great!



 
Since this post has to do with Winform Grids I've moved it to that forum.

I understand that you've most likely changed the code for testing purposes, but you do know you're filling the dataset three times with the same data, right? Without clearing the dataset first that means you'll get the data duplicated 3 times. Anyway, ...

What do you mean you can't display the datagrid. Does the datagrid not show up or does the data in the grid not show up?

I see you're using .NET V2.0. Using the dataAdapter/gridview is the old-school way of doing it. V2.0 has some great new data solutions which would include the TableAdapter/BindingSource/DataGridView classes. Using the new way, you can create data driven apps without writing one line of code. MSDN has some great videos here: Learning Resources for Visual Basic Express
 
Back
Top