PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

DataTableAdapters and transactions

 
 
Frank Hauptlorenz
Guest
Posts: n/a
 
      29th Apr 2009
Hi together,

I have a DataTableAdapter with different configured insert and update
commands.
Now I have to fire some of theses inside an transaction. For this I must
provide the transaction to the underlying SqlCommands.

I can't see how this can be done, because the commands are defined as
internal.
As a workaround I fire direct sql statements "START TRANSACTION" and so
on against the database.

Is there any better solution?

Thanks,
Frank
 
Reply With Quote
 
 
 
 
Jialiang Ge [MSFT]
Guest
Posts: n/a
 
      30th Apr 2009
Hello Frank

Here are some ideas that you can consider.

1. To access the internal SqlCommands of DataTableAdapter, you can use .NET
Reflection.

2. Consider using TransactionScope in .NET 2.0.
http://msdn.microsoft.com/en-us/libr...ansactionscope
aspx
This automatically makes a code block transactional.

Regards,
Jialiang Ge ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

 
Reply With Quote
 
HEX [MCPD]
Guest
Posts: n/a
 
      30th Apr 2009
Hi

are you using SP in Adapter?

why not to implement transaction in your SP and not to touch .NET

may be distributed transaction can help?


"Frank Hauptlorenz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi together,
>
> I have a DataTableAdapter with different configured insert and update
> commands.
> Now I have to fire some of theses inside an transaction. For this I must
> provide the transaction to the underlying SqlCommands.
>
> I can't see how this can be done, because the commands are defined as
> internal.
> As a workaround I fire direct sql statements "START TRANSACTION" and so on
> against the database.
>
> Is there any better solution?
>
> Thanks,
> Frank


 
Reply With Quote
 
Frank Hauptlorenz
Guest
Posts: n/a
 
      30th Apr 2009
Hi Jialing,

I build myself a workaround by defining an extension partial class which
does make the property accessible with methods ;-)

Thanks,
Frank


Jialiang Ge [MSFT] schrieb:
> Hello Frank
>
> Here are some ideas that you can consider.
>
> 1. To access the internal SqlCommands of DataTableAdapter, you can use .NET
> Reflection.
>
> 2. Consider using TransactionScope in .NET 2.0.
> http://msdn.microsoft.com/en-us/libr...ansactionscope
> .aspx
> This automatically makes a code block transactional.
>
> Regards,
> Jialiang Ge ((E-Mail Removed), remove 'online.')
> Microsoft Online Community Support
>
> =================================================
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> (E-Mail Removed).
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
> =================================================
>
>

 
Reply With Quote
 
Jialiang Ge [MSFT]
Guest
Posts: n/a
 
      4th May 2009
Nice, Frank!

- Jialiang Ge

 
Reply With Quote
 
Roberto H.
Guest
Posts: n/a
 
      16th Jul 2009
how can I use Reflection to access the internal SQLCommands of
DataTableAdapter?
give me an example please!

""Jialiang Ge [MSFT]"" wrote:

> Hello Frank
>
> Here are some ideas that you can consider.
>
> 1. To access the internal SqlCommands of DataTableAdapter, you can use .NET
> Reflection.
>
> 2. Consider using TransactionScope in .NET 2.0.
> http://msdn.microsoft.com/en-us/libr...ansactionscope
> .aspx
> This automatically makes a code block transactional.
>
> Regards,
> Jialiang Ge ((E-Mail Removed), remove 'online.')
> Microsoft Online Community Support
>
> =================================================
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> (E-Mail Removed).
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
> =================================================
>
>

 
Reply With Quote
 
SyntaxError
Guest
Posts: n/a
 
      17th Jul 2009
DataTableAdapter or TableAdapter?

A TableAdapter has the .DeleteCommand, .InsertCommand, .SelectCommand, and
..UpdateCommand properties.

"Roberto H." <(E-Mail Removed)> wrote in message
news:0FFA949B-A60C-4ACF-B067-(E-Mail Removed)...
> how can I use Reflection to access the internal SQLCommands of
> DataTableAdapter?
> give me an example please!
>
> ""Jialiang Ge [MSFT]"" wrote:
>
>> Hello Frank
>>
>> Here are some ideas that you can consider.
>>
>> 1. To access the internal SqlCommands of DataTableAdapter, you can use
>> .NET
>> Reflection.
>>
>> 2. Consider using TransactionScope in .NET 2.0.
>> http://msdn.microsoft.com/en-us/libr...ansactionscope
>> .aspx
>> This automatically makes a code block transactional.
>>
>> Regards,
>> Jialiang Ge ((E-Mail Removed), remove 'online.')
>> Microsoft Online Community Support
>>
>> =================================================
>> Delighting our customers is our #1 priority. We welcome your comments and
>> suggestions about how we can improve the support we provide to you.
>> Please
>> feel free to let my manager know what you think of the level of service
>> provided. You can send feedback directly to my manager at:
>> (E-Mail Removed).
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> =================================================
>>
>>


 
Reply With Quote
 
Roberto H.
Guest
Posts: n/a
 
      17th Jul 2009
I want to make a transaction with the adapters generated in the data set
designer. And the .DeleteCommand, .InsertCommand, .SelectCommand and
..UdateCommand are not available to assign the transaction.
How can I do?

"SyntaxError" wrote:

> DataTableAdapter or TableAdapter?
>
> A TableAdapter has the .DeleteCommand, .InsertCommand, .SelectCommand, and
> .UpdateCommand properties.
>
> "Roberto H." <(E-Mail Removed)> wrote in message
> news:0FFA949B-A60C-4ACF-B067-(E-Mail Removed)...
> > how can I use Reflection to access the internal SQLCommands of
> > DataTableAdapter?
> > give me an example please!
> >
> > ""Jialiang Ge [MSFT]"" wrote:
> >
> >> Hello Frank
> >>
> >> Here are some ideas that you can consider.
> >>
> >> 1. To access the internal SqlCommands of DataTableAdapter, you can use
> >> .NET
> >> Reflection.
> >>
> >> 2. Consider using TransactionScope in .NET 2.0.
> >> http://msdn.microsoft.com/en-us/libr...ansactionscope
> >> .aspx
> >> This automatically makes a code block transactional.
> >>
> >> Regards,
> >> Jialiang Ge ((E-Mail Removed), remove 'online.')
> >> Microsoft Online Community Support
> >>
> >> =================================================
> >> Delighting our customers is our #1 priority. We welcome your comments and
> >> suggestions about how we can improve the support we provide to you.
> >> Please
> >> feel free to let my manager know what you think of the level of service
> >> provided. You can send feedback directly to my manager at:
> >> (E-Mail Removed).
> >>
> >> This posting is provided "AS IS" with no warranties, and confers no
> >> rights.
> >> =================================================
> >>
> >>

>

 
Reply With Quote
 
Jim Rand
Guest
Posts: n/a
 
      18th Jul 2009
I've long since chucked the TableAdapter as well as Microsoft's designer as
both have major limitations. With that said, if you want to stick with the
TableAdapter, you might consider exposing the underlying DataAdapter. Here
is a code sample:

namespace WindowsApplication1 {

public partial class DataSet1
{
}
}

namespace WindowsApplication1.DataSet1TableAdapters
{
public partial class ProductTableAdapter
{
public System.Data.SqlClient.SqlDataAdapter daProductTable
{
get
{
this.Adapter.SelectCommand = this.CommandCollection[0];
return this.Adapter;
}
}
}
}


 
Reply With Quote
 
Roberto H.
Guest
Posts: n/a
 
      23rd Jul 2009
Do you have a Visual Basic Sample Please !

"Jim Rand" wrote:

> I've long since chucked the TableAdapter as well as Microsoft's designer as
> both have major limitations. With that said, if you want to stick with the
> TableAdapter, you might consider exposing the underlying DataAdapter. Here
> is a code sample:
>
> namespace WindowsApplication1 {
>
> public partial class DataSet1
> {
> }
> }
>
> namespace WindowsApplication1.DataSet1TableAdapters
> {
> public partial class ProductTableAdapter
> {
> public System.Data.SqlClient.SqlDataAdapter daProductTable
> {
> get
> {
> this.Adapter.SelectCommand = this.CommandCollection[0];
> return this.Adapter;
> }
> }
> }
> }
>
>
>

 
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
Supporting Transactions A La System.Transactions in a custom system aldousd666 Microsoft ADO .NET 2 9th May 2007 01:49 PM
"Supporting" transactions a la System.Transactions aldousd666 Microsoft Dot NET Framework 0 8th May 2007 02:36 PM
asp.net transactions =?Utf-8?B?QXNo?= Microsoft ASP .NET 1 12th Nov 2006 01:36 PM
Using Transactions in C# daniel schmied Microsoft ADO .NET 5 13th Apr 2005 04:21 PM
Mixing ADO.NET transactions and Stored Procedure Transactions James Walker Microsoft ADO .NET 1 27th May 2004 11:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:21 PM.