can some please tell me how to update a table with data from a dataset
what ive done is fill the dataset with the adapter and used a for Next loop to step into each row and display it into text boxes on the form.
on the save button
[CODE=vb]Dim sqlCon As SqlConnection = New SqlConnection(" Server=(local); Data Source=.\SQLEXP RESS;Initial Catalog=Payday1 0;Integrated Security=True;P ooling=False")
Dim daEmployee As New SqlDataAdapter( "select * from EarningsNew order by emplCode", sqlCon)
Dim dsEarningDescri ption As New DataSet("PayDay 10")
Private Sub Form2_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
sqlCon.Open()
daEmployee.Fill Schema(dsEarnin gDescription, SchemaType.Sour ce, "EarningsNe w")
daEmployee.Fill (dsEarningDescr iption, "EarningsNe w")
Dim x As Integer
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 0 Step -1
TextBox1.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 1 Step -1
TextBox2.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 2 Step -1
TextBox3.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 3 Step -1
TextBox4.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 4 Step -1
TextBox5.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 5 Step -1
TextBox6.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring()
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 6 Step -1
TextBox7.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 7 Step -1
TextBox8.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim sqlCommandBuild er As New SqlCommandBuild er(daEmployee)
daEmployee.Upda te(dsEarningDes cription, "EarningsNe w")
End Sub[/CODE]
what ive done is fill the dataset with the adapter and used a for Next loop to step into each row and display it into text boxes on the form.
on the save button
[CODE=vb]Dim sqlCon As SqlConnection = New SqlConnection(" Server=(local); Data Source=.\SQLEXP RESS;Initial Catalog=Payday1 0;Integrated Security=True;P ooling=False")
Dim daEmployee As New SqlDataAdapter( "select * from EarningsNew order by emplCode", sqlCon)
Dim dsEarningDescri ption As New DataSet("PayDay 10")
Private Sub Form2_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
sqlCon.Open()
daEmployee.Fill Schema(dsEarnin gDescription, SchemaType.Sour ce, "EarningsNe w")
daEmployee.Fill (dsEarningDescr iption, "EarningsNe w")
Dim x As Integer
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 0 Step -1
TextBox1.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 1 Step -1
TextBox2.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 2 Step -1
TextBox3.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 3 Step -1
TextBox4.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 4 Step -1
TextBox5.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 5 Step -1
TextBox6.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring()
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 6 Step -1
TextBox7.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
For x = dsEarningDescri ption.Tables(0) .Rows.Count - 1 To 7 Step -1
TextBox8.Text = dsEarningDescri ption.Tables(0) .Rows(x).Item(" EarnFixed").ToS tring
Next
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim sqlCommandBuild er As New SqlCommandBuild er(daEmployee)
daEmployee.Upda te(dsEarningDes cription, "EarningsNe w")
End Sub[/CODE]