Proprietà AdoSubmitConnection.Command
Ottiene o imposta il testo della stringa di comando SQL per un oggetto AdoSubmitConnection.
Spazio dei nomi: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)
Sintassi
Public MustOverride Property Command As String
Dim instance As AdoSubmitConnection
Dim value As String
value = instance.Command
instance.Command = value
public abstract string Command { get; set; }
Valore proprietà
Stringa di comando SQL per la connessione dati.
Osservazioni
La proprietà Command dell'oggetto ADOSubmitConnection contiene il testo del comando SQL utilizzato dalla connessione dati ADO per inviare i dati a un'origine dati esterna ADO (ActiveX Data Objects)/OLEDB.
![]() |
---|
Un oggetto ADOSubmitConnection può essere presente solo quando è presente un oggetto ADOQueryConnection corrispondente e le connessioni dati rappresentate da entrambi gli oggetti condividono lo stesso set di valori delle proprietà. Modificando il valore di questa proprietà per l'oggetto ADOSubmitConnection viene modificato anche il valore della stessa proprietà per l'oggetto ADOQueryConnection corrispondente. |
![]() |
---|
L'oggetto ADOSubmitConnection può essere utilizzato solo con i database di Microsoft SQL Server e di Microsoft Access. |
Possono accedere a questo membro solo moduli eseguiti nello stesso dominio del modulo aperto oppure moduli a cui sono state concesse autorizzazioni tra domini.
A questo tipo o membro può accedere solo il codice in esecuzione in moduli aperti in Microsoft Office InfoPath 2007.
Esempio
Nell'esempio seguente vengono utilizzati la proprietà Command della classe AdoSubmitConnection e il metodo Execute della classe DataConnection per eseguire una query in una tabella in un'origine dati secondaria denominata Employees. La query viene eseguita nella connessione dati creata in modalità progettazione di InfoPath al database che contiene la tabella Employees, denominato "EmployeesSubmit".
Innanzitutto, il valore immesso dall'utente nel campo my:EmpID viene utilizzato per aggiornare il testo del comando SQL tramite la proprietà Command. Viene quindi utilizzato il metodo Execute per aggiornare i dati recuperati da una connessione dati. In questo modo viene aggiornato il record visualizzato in un controllo Tabella ripetuta associato alla tabella Employees nel modulo. L'esempio richiede il campo my:EmpID nell'origine dati principale associato a un controllo Casella di testo in una visualizzazione che include un controllo Button per richiamare il codice seguente.
public void RefreshData_Clicked(object sender, ClickedEventArgs e)
{
// Get the Employees connection from the
// DataConnections collection.
AdoSubmitConnection myAdoSubmitConnection =
(AdoSubmitConnection)(this.DataConnections["EmployeesSubmit"]);
// Get the employee's ID from the EmpID field in
// the main data source.
XPathNavigator myNav =
CreateNavigator().SelectSingleNode("/my:myFields/my:EmpID",
NamespaceManager);
// Assign the value from the field to a variable.
string employeeID = myNav.InnerXml;
// Change the SQL command for Employees connection to retrieve
// the record of the Employee's ID entered by the user.
myAdoSubmitConnection.Command =
"select * from [Employees] where [EmployeeID] = " + employeeID;
// Execute the updated command against the data connection to
// refresh the data.
myAdoSubmitConnection.Execute();
}
Public Sub RefreshData_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
' Get the Employees connection from the
' DataConnections collection.
Dim myAdoSubmitConnection As AdoSubmitConnection = _
DirectCast(Me.DataConnections("EmployeesSubmit"), _
AdoSubmitConnection)
' Get the employee's ID from the EmpID field in
' the main data source.
Dim myNav As XPathNavigator = _
CreateNavigator().SelectSingleNode("/my:myFields/my:EmpID", _
NamespaceManager)
Dim employeeID As String = myNav.InnerXml
' Change the SQL command for Employees connection to retrieve
' the record of the Employee's ID entered by the user.
myAdoQueryConnection.Command = _
"select * from [Employees] where [EmployeeID] = " & employeeID
' Execute the updated command against the data connection to
' refresh the data.
myAdoSubmitConnection.Execute()
End Sub
Vedere anche
Riferimenti
Classe AdoSubmitConnection
Membri AdoSubmitConnection
Spazio dei nomi Microsoft.Office.InfoPath