Note that there are some explanatory texts on larger screens.

plurals
  1. POHow Can I Expose Private Fields using a Partial Class in VB.NET?
    primarykey
    data
    text
    <p>This is my first post on Stack Overflow so please exuse (and feel free to point out) any n00b mistakes.</p> <p>I am trying to implement transactions across multiple TableAdapters in VB.NET (using Visual Studio 2010) by extending the partial class as described in the following examples:</p> <p><a href="http://blah.winsmarts.com/2006/06/18/the-definitive-tableadapters--transactions-blog-post.aspx" rel="nofollow">http://blah.winsmarts.com/2006/06/18/the-definitive-tableadapters--transactions-blog-post.aspx</a></p> <p>madprops.org/blog/typed-datasets-and-sqltransaction/</p> <p>stackoverflow.com/questions/2342289/net-tableadapter-to-dataadapter</p> <p>However, when I attempt to expose any of the private fields created by the designer they are underlined in the editor with the following error:</p> <blockquote> <p>'_adapter' is not declared. It may be inaccessible due to its protection level.</p> </blockquote> <p>Searching this site as well as google has not revealed anything useful, but perhpas I'm searching the wrong keywords.</p> <p>Here is the code in MyDataset.vb</p> <pre><code>Partial Public Class MyTableAdapter Public Property MyTransaction() As SqlTransaction Get Return _adapter.SelectCommand.Transaction End Get Set(ByVal value As SqlTransaction) If _adapter Is Nothing Then InitAdapter() End If Connection = value.Connection _adapter.InsertCommand.Transaction = value _adapter.UpdateCommand.Transaction = value _adapter.DeleteCommand.Transaction = value End Set End Property End Class </code></pre> <p>and here is the designer code:</p> <pre><code>Partial Public Class MyTableAdapter Inherits Global.System.ComponentModel.Component Private WithEvents _adapter As Global.System.Data.SqlClient.SqlDataAdapter Private _connection As Global.System.Data.SqlClient.SqlConnection Private _transaction As Global.System.Data.SqlClient.SqlTransaction Private _commandCollection() As Global.System.Data.SqlClient.SqlCommand </code></pre> <p>Am I missing something, or is this not possible in VB (all of the examples I've seen are in C#)?</p> <p>TIA for any help!</p> <p>JE</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload