Hi,
Here is a sample that adds 3 tables to a dataset and sets up
relations between them.
http://www.onteorasoftware.com/downloads/multigrids.zip
Ken
---------------------------
"Manuel Canas" <(E-Mail Removed)> wrote in message
news:gznIc.22664$2i3.20434@clgrps12...
> Hey guys,
>
> This code was posted by Cor Ligther some rows below here. hey bud if you
> read this one can you help me out here or anybody that know the answer to
> this one.
>
> How would I add a second table to this DataSet?
>
> Thanks Guys.
>
> Private Sub FillDatasetAndBindings()
> ds.Clear()
> Dim sqlString As String = "Select * from countries"
> da = New OleDb.OleDbDataAdapter(sqlString, conn)
> da.Fill(ds)
> Dim dt As DataTable = ds.Tables(0)
> dv = New DataView(dt)
> dv.Sort = "Id"
> cma = DirectCast(BindingContext(dv), CurrencyManager)
> Dim cmb As New OleDb.OleDbCommandBuilder(da)
> TextBox1.DataBindings.Clear()
> TextBox2.DataBindings.Clear()
> TextBox1.DataBindings.Add("text", dv, "Id")
> TextBox2.DataBindings.Add("text", dv, "Name")
> ListBox1.DataSource = dv
> ListBox1.DisplayMember = "Name"
> If ds.Tables(0).Rows.Count = 0 Then
> cma.AddNew()
> TextBox1.Focus()
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Button1.Click
> 'Adding of a new row
> cma.AddNew()
> TextBox1.Focus()
> End Sub
> Private Sub Button2_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Button2.Click
> 'Delete
> dv(cma.Position).Delete()
> End Sub
> Private Sub Button3_Click_1(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Button3.Click
> 'Add it to the dataset and to the
> cma.EndCurrentEdit()
> End Sub
> Private Sub Button4_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Button4.Click
> 'Write it to the database
> cma.EndCurrentEdit()
> If ds.HasChanges Then
> Try
> da.Update(ds)
> Catch ex As OleDb.OleDbException
> MessageBox.Show(ex.Message, "OleDbException")
> Exit Sub
> Catch ex As Exception
> MessageBox.Show(ex.Message, "GeneralException")
> Exit Sub
> End Try
> End If
> End Sub
> ////
>
> Manuel
>
>