2013-04-18 2 views
0

Je travaille sur une forme infopath en utilisant MS Access comme base de données.Echec de l'échec de VB (Infopath et Access)

Sur le formulaire, je veux vérifier les courriels pour les doublons et j'essaie de le faire en exécutant une requête SQL à partir du code VB suivant. Je souhaite continuer avec une instruction if, then, else pour demander si le doublon est trouvé. Cependant, je reçois l'erreur suivante lorsque je tente d'exécuter le code:

System.Net.WebException was unhandled by user code 
Message="The query method on the Document object failed. 
Operation aborted" 

Qu'est-ce que je fais mal? Merci d'avance pour une réponse.

Notes:

J'ai adapté le code de - http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.adoqueryconnection.command.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

éléments du Code sont:

Mainconnection = connection name 
"/dfs:myFields/dfs:dataFields/d:Candidate_Tracking_Database/@Email" = Xpath of the input text box 
[Email] = Field name in the [Candidate_Tracking_Database] table 

erreur complète est:

System.Net.WebException was unhandled by user code 
Message="The query method on the Document object failed. 
Operation aborted 
" 
Source="Microsoft.Office.InfoPath.Client.Internal.Host" 
StackTrace: 
    at  Microsoft.Office.InfoPath.Internal.MomExceptionHelper.ExecuteDataConnectionAction(OMCall d) 
    at Microsoft.Office.InfoPath.Internal.AdoQueryConnectionHost.Execute() 
    at Candidate_Registration.FormCode.CTRL125_7_Clicked(Object sender, ClickedEventArgs e) in C:\Infopath\InfoPath Projects\Candidate Registration\FormCode.vb:line 300 
    at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent) 
    at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent) 

Répondre

0

Essayez ceci:

myAdoConnection.Command = _ "select [Email] from [Candidate_Tracking_Database] where [Email] =" & email

ou ceci:

myAdoConnection.Command = _ "select [Email] from [Candidate_Tracking_Database] where [Email] ='" & email & "'"

+0

La deuxième ligne de code a fonctionné. Cependant, il y a une autre erreur. Je vais vérifier dans la soirée et revenir à vous les gars !! Merci beaucoup!! – user2204330

+0

Tout est super bien !! ... Je vous remercie!! – user2204330