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 1 1426
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" <mc*****@hotmail.com> 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric Petruzzelli |
last post by:
If I fill my dataset and there is no data. The dataset is still created
with zero rows (all columns are there). When I add my first row using
the script below, it takes over 2 seconds to add??? If...
|
by: Duncan Spence |
last post by:
Hi all,
I'm sure I'm doing something silly here, but can't see it!
I'm creating a series of combo boxes on a Windows Form in VB.NET.
The lists of all of the comboboxes are identical and are...
|
by: Jim Heavey |
last post by:
Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that...
|
by: Andrew |
last post by:
Hey all,
I am very new to ASP.Net (and .Net in general), but that isn't stopping the
boss from wanting to begin new projects in it. This latest project has me
kinda stumped and after a couple...
|
by: Trevor |
last post by:
Hey,
I am trying to do this tutorial on the microsoft site :
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dndotnet/html/usingadonet.asp
I can get everything to work up to...
|
by: Geoff Jones |
last post by:
Hi
Can anybody help me with the following, hopefully simple, question?
I have a table which I've connected to a dataset. I wish to add a new column
to the beginning of the table
and to fill...
|
by: Niels Jensen |
last post by:
I have the following code in a Sub which is called by a do loop statement for
each line starting with unit info in an e-mail based game that I play. I'm
exctracting the keywords from the text and...
|
by: Rudy |
last post by:
Hi all,
I know this is easy, just can't seem to get it. I have a windows form, and
a text box, with a value already in it. I need to add that value to a table.
It's just one value, so the entire...
|
by: TB |
last post by:
Hi All:
As a newbie to ASP.NET, I think I have understood a dataset as a kind
of container where I can store several datatables to used during the
lifetime of a page. With that in mind I written...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |