PC Review


Reply
Thread Tools Rate Thread

ADO.NET Update SQL View

 
 
graigcrawford@yahoo.com
Guest
Posts: n/a
 
      4th Jan 2006
I have created a view in SQL server 2000 that joins two one-to-one
tables. This view is updateable from SQL enerprise manager as all of
the keys are present to perform updates. In VB6, I could simply create
an ADO Recordset that queries this view, make the recordset optimistic,
and updates would be performed automatically when the .Update method
was invoked. However, in ADO.NET this appears to be impossible. I
have created a stored procedure that queries this view and bound the
resulting dataset to a grid. MY issue is I cannot make this dataset
updateable. Obviously, the command builder will not generate the
Update statement because there is a table join. I have tried creating
a stored procedure fot the update but am receiving an error - which
gives me no indication as to what the actual problem is. I cannot
create two adaptors because I need to bind he dataset to a single grid.
What is the solution? It seems as though ADO.NET is a huge step
backward from ADO. Any help would be greatly appreciated

 
Reply With Quote
 
 
 
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      4th Jan 2006
One of the most common mistakes we all have to deal with on a daily basis is
this: thinking that ADO.NET should behave like ADO classic.
In ADO classic, the UPDATE SQL action commands are created using a runtime
engine that analyzes the SELECT query and after several editions (about 5)
it figured out how to update Views and other JOINed products.
In ADO.NET there is no runtime engine to do this. You can choose to use the
CommandBuilder (as the design-time tools do) to generate the UpdateCommand
but it's pitiful when compared to the logic in ADO classic.
The team at Microsoft expects you to build your own SQL UpdateCommand and
other action commands for this type of problem. If you really want to update
the View, you can write your own UPDATE and past it into the
UpdateCommand.CommandText and setup the Parameters collection. Not trivial,
but also doable. I discuss this in my book on ADO.NET.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have created a view in SQL server 2000 that joins two one-to-one
> tables. This view is updateable from SQL enerprise manager as all of
> the keys are present to perform updates. In VB6, I could simply create
> an ADO Recordset that queries this view, make the recordset optimistic,
> and updates would be performed automatically when the .Update method
> was invoked. However, in ADO.NET this appears to be impossible. I
> have created a stored procedure that queries this view and bound the
> resulting dataset to a grid. MY issue is I cannot make this dataset
> updateable. Obviously, the command builder will not generate the
> Update statement because there is a table join. I have tried creating
> a stored procedure fot the update but am receiving an error - which
> gives me no indication as to what the actual problem is. I cannot
> create two adaptors because I need to bind he dataset to a single grid.
> What is the solution? It seems as though ADO.NET is a huge step
> backward from ADO. Any help would be greatly appreciated
>



 
Reply With Quote
 
graigcrawford@yahoo.com
Guest
Posts: n/a
 
      4th Jan 2006
Bill,

Thanks for the response. Unfortunately I have tried writing a Stored
procedure for my update - and I receive a very helpful system.data.dll
error which tells me absolutely nothing about the source of the
problem. I setup the Update command of my adaptor so that the stroed
procedure parameters map to each field in my dataset. The update
command works fine when I only update one of the two tables used in the
view - but when I try to update a field from each table - here comes
the system.data.dll error. Is there anything I can try because I am
ready to scrap .NET and return to VB6 simply for the data access
benefits.

 
Reply With Quote
 
graigcrawford@yahoo.com
Guest
Posts: n/a
 
      4th Jan 2006
Bill,

Thanks for the response. Unfortunately I have tried writing a Stored
procedure for my update - and I receive a very helpful system.data.dll
error which tells me absolutely nothing about the source of the
problem. I setup the Update command of my adaptor so that the stroed
procedure parameters map to each field in my dataset. The update
command works fine when I only update one of the two tables used in the
view - but when I try to update a field from each table - here comes
the system.data.dll error. Is there anything I can try because I am
ready to scrap .NET and return to VB6 simply for the data access
benefits.

 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      4th Jan 2006
What's the error? Did you trap it with an exception handler?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Bill,
>
> Thanks for the response. Unfortunately I have tried writing a Stored
> procedure for my update - and I receive a very helpful system.data.dll
> error which tells me absolutely nothing about the source of the
> problem. I setup the Update command of my adaptor so that the stroed
> procedure parameters map to each field in my dataset. The update
> command works fine when I only update one of the two tables used in the
> view - but when I try to update a field from each table - here comes
> the system.data.dll error. Is there anything I can try because I am
> ready to scrap .NET and return to VB6 simply for the data access
> benefits.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you update through a view? =?Utf-8?B?R3JlZyBQ?= Microsoft Dot NET 6 11th May 2006 08:14 AM
update from datasheet view =?Utf-8?B?SmVmZg==?= Microsoft Access Forms 5 7th Apr 2005 12:51 AM
Cant View PDF in Explorer any more since i did MS Update Michael Windows XP Internet Explorer 1 4th Sep 2004 03:42 PM
How to update view? jaYPee Microsoft ADO .NET 7 14th Jan 2004 05:55 AM
How to update view? jaYPee Microsoft VB .NET 7 14th Jan 2004 05:55 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:35 AM.