|
-
Oct 16th, 2004, 03:08 AM
#1
Thread Starter
Junior Member
update database from dataset
Hi,
I am binding a dataset to the datagrid. In the datagrid, i am editing a record. My table doesn't have primary key. I think commandbuilder doesn't work becoz of no primary key. Pls tell me how to update the database from the dataset using the dataadapter. I am using Access database.
private sub btnupdate_click(...)
if ds.haschanges then
da.update(ds.tables("Customer")
endif
end sub
Thanks in advance
-
Oct 16th, 2004, 03:12 AM
#2
it wont update if you dont have a primary key on your table..
dataadapter seeks for the primary key.
-
Oct 16th, 2004, 03:18 AM
#3
Thread Starter
Junior Member
Is any other way to update the dataset into database?
-
Oct 16th, 2004, 03:32 AM
#4
Originally posted by KnowledgeSeeker
Is any other way to update the dataset into database?
Yes. and dont ask me how?
and BTW why wont you put primary key on your table?
-
Oct 16th, 2004, 05:20 AM
#5
Addicted Member
You need to create sql commands for the dataadapter.
-
Oct 16th, 2004, 05:37 AM
#6
Thread Starter
Junior Member
can u give me example? My dataset may contains around 5 records which are added or edited records, how to store it in database using dataadapter.
-
Oct 16th, 2004, 06:10 AM
#7
Thread Starter
Junior Member
I have 2 tables "Child" and "Relations"
In table "Child",
Roll_No Child_Name Class
===== ======== ====
1000 John I
1001 David II
In table "Relations",
Parent_Name Roll_No Role
========== ====== ====
Robinson 1000 Father
Paul 1001 Father
Jennifer 1001 Mother
Paul 1000 Carer
I am showing the "relations" table records of Roll_No = 1000 in datagrid using dataset, so it will show Robinson & Paul Records. Suppose if i am modifying the role of Paul to "Grand Parent" from "Carer" and try to update, it will given an error because, i don't have Primary Key in my table. Will it work if I add Auto Increment (PK) field?
I am thinking of doing it in this way. before updating the dataset into the database, first deleting the Records having Roll_No = 1000 in "relations" table and then adding into "Relations" table with modified dataset using dataadapter. Is it the correct way?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|