Insert Row Into Table Object

bloukewer

Well-known member
Joined
Jul 2, 2004
Messages
88
Programming Experience
3-5
How do you insert a row into a table object? I need to read data from the database into a table and then add a row of custom data into the table-object. Any examples would be great!
 
bloukewer said:
How do you insert a row into a table object? I need to read data from the database into a table and then add a row of custom data into the table-object. Any examples would be great!

try this one:
VB.NET:
	Dim da As New SqlDataAdapter("select * from employees", cn)
	Dim dt As New DataTable()
	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		da.Fill(dt)
		DataGrid1.DataSource = dt
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim dr As DataRow = dt.NewRow
		dr(0) = TextBox1.Text
		dt.Rows.Add(dr)
	End Sub
 
Back
Top