Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prob with adding new data into table

Status
Not open for further replies.

sup919

Programmer
Jan 10, 2002
31
TH
hi there,
i ve got a problem with adding data into database , basically i m using my own typeDataset to insert into table when it run, it run properly but didnt store any value into database .. here is my code

Dim tdsReligion As New dsReligion
con1.Open()

daReligion.Fill(tdsReligion)
Dim rows As dsReligion.ReligionTypeRow = tdsReligion.ReligionType.NewReligionTypeRow()


rows.ReligionName = TextBox1.Text
'rows.ReligionID = 1

tdsReligion.ReligionType.AddReligionTypeRow(rows)

tdsReligion.AcceptChanges()

daReligion.Update(tdsReligion)

con1.Close()

it does nothing when i did check the debug in the autofield everything is adding correctly but not in the a watch1 no value is adding at all !!! i m new to this please anyone can suggest what should i do
 
You are calling AcceptChanges befor calling Update. AcceptChanges sets the RowState of all rows in the datatable (tdsReligion) in the dataset to DataRowState.Unchanged. Thus, when Update is called it "sees" that there are no rows with changes, and so nothing is done. The fix is easy, just put AcceptChanges after Update:

daReligion.Update(tdsReligion)

tdsReligion.AcceptChanges()

Actually, you don't even need to call AcceptChanges, as Update does an AcceptChanges when it executes.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top