Adding a second table to this DataSet.

M

Manuel Canas

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top