Saturday, March 24, 2012

What is the best way to make changes to a DataAdapter?

I have just converted one of my websites from ASP.NET 1.1 to ASP.NET 2.0
using the wizard.
What is the best way to update the DataAdapters if there are some database
changes? I really hate to mess around with the code in the "Web Form Designe
r
Generated Code" section. There must be another way. Can anyone please let me
know? Thanks.
RichardThe DataAdapter itself is not something you "make changes" to - it is simply
a conduit that exposes (among other methods) an Update method, with Select,
Update, Insert and Delete Command objects that it tells to perform their wor
k
on each row of the datasource that is passed into it based on the RowState o
f
each row. Hope that clarifies.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Richard" wrote:

> I have just converted one of my websites from ASP.NET 1.1 to ASP.NET 2.0
> using the wizard.
> What is the best way to update the DataAdapters if there are some database
> changes? I really hate to mess around with the code in the "Web Form Desig
ner
> Generated Code" section. There must be another way. Can anyone please let
me
> know? Thanks.
> Richard
>
In ASP.NET 1.1, you can remove the old DataAdapter, then drag and drop a
table from the server explorer to generate a new DataAdapter, with updated
SELECT, UPDATE, INSERT, and DELETE commands. In ASP.NET 2.0, this will
generate a SqlDataSource with a GridView.
I am just trying to find a "easy" way to update those SELECT, UPDATE,
INSERT, and DELETE commands for an out of date DataAdapter.
Thanks,
Richard
"Peter Bromberg [C# MVP]" wrote:
> The DataAdapter itself is not something you "make changes" to - it is simp
ly
> a conduit that exposes (among other methods) an Update method, with Select
,
> Update, Insert and Delete Command objects that it tells to perform their w
ork
> on each row of the datasource that is passed into it based on the RowState
of
> each row. Hope that clarifies.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Richard" wrote:
>
So long as your code can get a reference to the DataAdapter, you can do
whatever you want with its commands, and re-use it.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Richard" wrote:
> In ASP.NET 1.1, you can remove the old DataAdapter, then drag and drop a
> table from the server explorer to generate a new DataAdapter, with updated
> SELECT, UPDATE, INSERT, and DELETE commands. In ASP.NET 2.0, this will
> generate a SqlDataSource with a GridView.
> I am just trying to find a "easy" way to update those SELECT, UPDATE,
> INSERT, and DELETE commands for an out of date DataAdapter.
> Thanks,
> Richard
> "Peter Bromberg [C# MVP]" wrote:
>
It seems there is not an easier way. More code changes, I guess.
Thanks for your reply,
Richard
"Peter Bromberg [C# MVP]" wrote:
> So long as your code can get a reference to the DataAdapter, you can do
> whatever you want with its commands, and re-use it.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Richard" wrote:
>
If you are doing things the "Visual" way, you can just delete the resulting
Gridview from the page, and leave the new SqlDatasource, when you should be
able to use to databind to your original DataGrid.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Richard" wrote:
> It seems there is not an easier way. More code changes, I guess.
> Thanks for your reply,
> Richard
>
> "Peter Bromberg [C# MVP]" wrote:
>
Sure. If you use Stored Procedures instead of generated SQL statements, you
can change the Stored Procedures without touching the DataAdapter.
HTH,
Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com
Expect the unaccepted.
"Richard" <Richard@.discussions.microsoft.com> wrote in message
news:F903CD80-5524-4C64-81D3-5E436B201F70@.microsoft.com...
> In ASP.NET 1.1, you can remove the old DataAdapter, then drag and drop a
> table from the server explorer to generate a new DataAdapter, with updated
> SELECT, UPDATE, INSERT, and DELETE commands. In ASP.NET 2.0, this will
> generate a SqlDataSource with a GridView.
> I am just trying to find a "easy" way to update those SELECT, UPDATE,
> INSERT, and DELETE commands for an out of date DataAdapter.
> Thanks,
> Richard
> "Peter Bromberg [C# MVP]" wrote:
>

0 comments:

Post a Comment