|
-
Aug 17th, 2007, 09:54 AM
#1
Thread Starter
Addicted Member
[2005] why dataadapter fails in updating 2 diffrent tables
Hi
i make the dataadapter get data and view in datagridview successfully
and the same adapter let it get another table by changing the select statement and view it in another datagridview till now ok.
i have 2 update buttons every one for each table
the first dataset i call
da.update(ds1)
and the second
da.update(ds2)
i found that the second one raise exception says "Object renfrence is set to none" means that the dataadapter is no longer exists ?!
any explanation
by the way i can make both tables in one dataset and they will work. but i want explanation for this error.
thanks in advance.
-
Aug 17th, 2007, 10:06 AM
#2
Re: [2005] why dataadapter fails in updating 2 diffrent tables
Hi.
Did you put the NEW keyword when you declared dataadapter?
"The dark side clouds everything. Impossible to see the future is."
-
Aug 17th, 2007, 01:16 PM
#3
Thread Starter
Addicted Member
Re: [2005] why dataadapter fails in updating 2 diffrent tables
thanks for reply
i will check my code again and tell you
-
Aug 17th, 2007, 02:46 PM
#4
Thread Starter
Addicted Member
Re: [2005] why dataadapter fails in updating 2 diffrent tables
yes i create new adapter and i don't know why still the error
but one question
can i fill the dataset with an adapter and update it with another one ?
thanks in advance.
-
Aug 17th, 2007, 03:21 PM
#5
Re: [2005] why dataadapter fails in updating 2 diffrent tables
I think you remove the data bindings when you renew the data adapter. Create a data adapter for each data table and give it a try.
-
Aug 17th, 2007, 09:43 PM
#6
Re: [2005] why dataadapter fails in updating 2 diffrent tables
You're abusing the DataAdapter. The purpose of a DataAdapter is to provide the link between a single result set and the database. The DataAdapter encapsulates the four Commands that will operate on that result set. You should not be changing any SQL code in DataAdapter. The whole point is that the DeleteCommand, InsertCommand and UpdateCommand are supposed to save the changes made to the data retrieved by the SelectCommand. If you change the SelectCommand to get different data then what do the other commands relate to? If you are operating on two different result sets, which basically means DataTables, then you should have two different DataAdapters.
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
|