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!

insert data into database problem

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()

please help
 
The problem is that you are calling AcceptChanges before the Update. AcceptChanges does just that - it accepts all of the changes to the data, and marks them as not being changed. then when you call the Update, it sees that there are no changes to the data and so no update/insert occurs.

Just put the AcceptChanges after the Update:

daReligion.Update(tdsReligion)

tdsReligion.AcceptChanges()

Actually, you don't really need to call AcceptChanges, because it is called automatically as part of the Update (after the Update is finished).



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
 
By the way, this is really a forum for VB6 and databases. You might want to post to the VB.Net forum in future.

Bob
 
Maybe the forum should be renamed to VB6 Databases, because these days a lot of people refer to VB.NET as Visual Basic as well.

 
Yup, but I suspect that renaming a forum has problems of its own.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top