Adding New Row...

  • Thread starter Thread starter peg
  • Start date Start date
P

peg

I'm new to ado.net/asp.net -

After a user fills in a webform I'm trying to add a row to the table with
its values.....
but after running this code (no errors) and i check my table - nothing is
ever added. Am I doing something wrong?

Dim rowNew As DataSet2.QCReportMainRow = DataSet21.QCReportMain.NewRow

rowNew.CientName = txtClientName.Text
rowNew.ReportName = txtClientName.Text & " - " & txtEffectiveDate.Text
rowNew.PresentedBy = txtPresentedBy.Text
rowNew.EffectiveDate = txtEffectiveDate.Text
rowNew.PreparedOn = txtPreparedOn.Text
rowNew.AnnualRate = AnnualRates.SelectedIndex
rowNew.Composite = CompRating.SelectedIndex

DataSet21.QCReportMain.Rows.Add(rowNew)

'TRYING TO SEE RECORD COUNT FROM TABLE AFTER ADD ROW
Label11.Text = DataSet21.QCReportMain.Rows.Count()

'Get AutoIncr filed of newly added row.
Session("RptID") = rowNew.ReportID
 
Peg, without submitting the update to the DB like Kerry mentioned, the only
way to see it through post backs is to serializes it something, ie store it
in session/view state and then bind to it on the next page load. Best was
is to save it to the db unless somehow that's not necessary.
 
Peg,

You're simply missing an .EndEdit():

rowNew.EndEdit()
DataSet21.QCReportMain.Rows.Add(rowNew)

~~Bonnie
 
Back
Top