PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Re: Only First Insert Works

Reply

Re: Only First Insert Works

 
Thread Tools Rate Thread
Old 30-06-2003, 05:51 PM   #1
Val Mazur
Guest
 
Posts: n/a
Default Re: Only First Insert Works


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.



  Reply With Quote
Old 01-07-2003, 01:10 AM   #2
hamid S
Guest
 
Posts: n/a
Default Re: Only First Insert Works

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.

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off