PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Re: Only First Insert Works
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Re: Only First Insert Works
![]() |
Re: Only First Insert Works |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
How do you do inserting? -- Val Mazur Microsoft MVP "hamid S" <donhamid2@yahoo.com> wrote in message news:c3996579.0306282208.465f9e6e@posting.google.com... > Hi, > > When I try to insert to an empty Database, only the first record is > inserted. Additional update command only inserts rows to the DataSet, > but not to Database. What could be wrong. > > Thanks in advance for help. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Hi Val,
Thanks for reply. Here is my code: Private Sub btnAddToDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddToDB.Click Dim comm As New SqlClient.SqlCommandBuilder(NewDataAdapter) 'Get the one table from the myDataSet Dim myDataTable As DataTable = NewDataSet.Tables(0) Dim myNewRow As DataRow = myDataTable.NewRow myNewRow("id") = txtId.Text myNewRow("first") = txtFirst.Text myNewRow("last") = txtLast.Text myDataTable.Rows.Add(myNewRow) NewDataAdapter.InsertCommand.Connection = NewConnection NewDataAdapter.InsertCommand = comm.GetInsertCommand NewDataAdapter.Update(NewDataSet, "Table3") NewDataSet.AcceptChanges() NewDataAdapter.InsertCommand.Connection.Close() NewDataAdapter.Fill(NewDataSet, "Table3") End I am using Windows XP home. Thanks Again "Val Mazur" <group51a@hotmail.com> wrote in message news:<eJM3xAzPDHA.1624@tk2msftngp13.phx.gbl>... > Hi, > > How do you do inserting? > > -- > Val Mazur > Microsoft MVP > > "hamid S" <donhamid2@yahoo.com> wrote in message > news:c3996579.0306282208.465f9e6e@posting.google.com... > > Hi, > > > > When I try to insert to an empty Database, only the first record is > > inserted. Additional update command only inserts rows to the DataSet, > > but not to Database. What could be wrong. > > > > Thanks in advance for help. |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

