creating a dataset

hp76

New member
Joined
Apr 4, 2005
Messages
2
Programming Experience
3-5
Hi,

How do I go about creating a dataset to update a database.

I started off with this:
Private dsDataContacts As New DataSet

Dim dtDataContacts As DataTable = New DataTable("Contacts")

dsDataContacts.Tables.Add(dtDataContacts)

'Build the Contacts table.

With dtDataContacts.Columns

.Add("ClientId", ToString)

.Add("ComanyName", ToString)

etc...
End With

How do I now populate the dataset via data from text controls?

H
 
VB.NET:
 Dim ds As New DataSet()
	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		ds.Tables.Add(New DataTable("dt"))
		ds.Tables(0).Columns.Clear()
		ds.Tables(0).Columns.Add(New DataColumn("truckID"))
		ds.Tables(0).Columns.Add(New DataColumn("Company"))
		ds.Tables(0).Columns.Add(New DataColumn("Typeof"))
	End Sub

'populating a data to your datatable.
	Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim dr As DataRow = ds.Tables(0).NewRow
		dr(0) = Me.TextBox1.Text
		dr(1) = Me.TextBox2.Text
		dr(2) = Me.TextBox3.Text
		ds.Tables(0).Rows.Add(dr)
		ListBox1.Items.Add(TextBox1.Text)
		Me.cleartextbox()
	End Sub
 
Back
Top