Partial class e namesapce

martedì 10 luglio 2007 - 10.29

liuc Profilo | Junior Member

ciao a tutti
ho un problema, forse banale, ma al quale non trovo soluzione (sono un novizio dopotutto).

Nella mia applicazione utilizzo un dataset tipizzato (DataSetContatti).
Il sistema ha creato le sue belle classi , ora però vorrei aggiungere (in un file a parte) alcuni metodi alla classe Table_RECAPITOTableAdapter (che si trova nel Namespace DataSetContattiTableAdapters) ma non riesco ad accedere alle variabili dichiarate nella classe generata dal sistema.

Di seguito riporto il codice della classe generata e quello che ho scritto a parte per cercare di accedere alla collezione _commandCollection.

Namespace DataSetContattiTableAdapters

Partial Public Class Table_RECAPITOTableAdapter
Inherits System.ComponentModel.Component

Private _commandCollection() As System.Data.SqlClient.SqlCommand
....
....
End Class

End Namespace



File : Utility.vb

Namespace DataSetContattiTableAdapters

Partial Public Class Table_RECAPITOTableAdapter

Public Function GetCommand(ByVal commandIndex As Integer) As Object
Return _commandCollection(commandIndex)
End Function

End ClassEnd Namespace



Dov'è che sbaglio ?

Cteniza Profilo | Guru

Ho fatto qualche cosa del genere per il mio blog su mysql
http://community.visual-basic.it/lucianob/articles/19470.aspx

Namespace dbprovaDataSetTableAdapters
Partial Public Class tableprovaTableAdapter
Public Sub GeneraCommands()
Me.InitCommandCollection()
Dim cn As New MySql.Data.MySqlClient.MySqlConnection(My.Settings.dbprovaConnectionString)
Dim cm As New MySql.Data.MySqlClient.MySqlCommand("SELECT codice, descrizione, valore FROM tableprova", cn)
cn.Open()
Dim da As New MySql.Data.MySqlClient.MySqlDataAdapter(cm)
Dim cmd As New MySql.Data.MySqlClient.MySqlCommandBuilder(da)
Me._adapter = da

Me._commandCollection(0) = cm
Me._connection = cn
Me._commandCollection(1) = cmd.GetDeleteCommand()
Me._commandCollection(2) = cmd.GetInsertCommand()
Me._commandCollection(3) = cmd.GetUpdateCommand()

cn.Close()
End Sub
Public ReadOnly Property MostraCommandCollection() As MySql.Data.MySqlClient.MySqlCommand()
Get
If (Me._commandCollection Is Nothing) Then
Me.InitCommandCollection()
End If
Return Me._commandCollection
End Get
End Property
End Class
End Namespace
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5