?? ???????? ADO ???? ????? ?? ??? ???? InfoPath ??????? ?????? ??? ??????????? ?????? ?? ????? ???? ????

???? ?????? ???? ??????
???? ID: 826992 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

Microsoft Office InfoPath ???????? Microsoft SQL Server ?? Microsoft Access ??? ??????? ??? InfoPath ???????? ??? ?? ???? SQL ??????? ?? ???? Access ??????? ??? ?????? ?????? ???, ???? Microsoft ActiveX ???? ?????????? (ADO) ?? ????? ???? ??????? ?? ???? ???? ???? ???, InfoPath ????????? ?? ??? ??? ??????? ???? ?? ??? ?????? ?? ?????? ???? ???

???? ????? ?????? ?? ???, InfoPath ?? ???????????? ??????? ?????? ????? ?????????? ?? ??? ?? ?????? ?? ??? ????? ??? ?? ????????? ???????????? ????? ?????????? ?? ?????? ?? ???? SQL ???????? ?? ????? ???? ?? ???? ????? ?????? ?? ???? ??? ?? ??????? ????? ?? ??? ????? ????? ????? ??? ?? ????????? ?????? ?? ??? ???? ?????? ?????? ?? ??? ???? ????? ?????? ?? ?? ?????? ???? ??????????? ???? ?? ????? ???? ???

???? ???????? ??? ???? ??????????? ???? ??? SQL ?????? ??? ?? ???? Access ?????? ?? ????? ???? ??? ????????? ???? ?? ??? InfoPath ??? ????? ???? ?? ??? ????? ??? ??????ADOAdapter???????? ???

???? ???????

InfoPath ???? ?? ?????? ???? ??????? ?? ??? ??? cast ??AdoQueryConnection???????? ??? ?? ???? ??????? ???? ?? ??? ?? ????? ?????? ?? ???? ??? ??????? ??? ???? ?? ??? ???? ??:
  • ??????? ????????
  • SQL ???? ???
  • ????-??? ???
?? ????? ????AdoQueryConnection????????, ???? ???? ??????????? ???? ?? ????? ?????? ?? ???? ?????? ?? ??? ???? SQL ??? ????????? ?? ???? ????

?? ???? ??? ??????? SQL ??????? ?? Access ??????? ?? ??? ???? ???? ??? ????? ?????? Microsoft Office Access 2007 ?? ??? ?? Microsoft Office 2010 ?? ????? ?? ??? ????? ???? ??? ?? ????????? ??????? ?? ????? ?????

??????? ?????

??? ???? ??? ?? ????????? ????? ??????? ????? ?? InfoPath ?? ???? ??????? ???? ?? ????, ??????? ??????? ?????? ??? ???? ?? ???, ????? ????? ?? ???? ????:

  1. Microsoft Office Access ??????? ?????
  2. ????????? ??????????????, ?? ??? ????????? ????????.
  3. ?? ??? ????????????????????, ?? ???? ????????.

??????? ???????? ??????? ??????? ????

?? ??? ????? ?? ?? ???? ?????? ??? InfoPath ??????? ??????? ???? ?? ???? ?? ?????? ????????? ?????? ?? ????????? ??????? ?? ????? ???? ??? ???????? ?? ?????? ???? ??????? ????? ?? ???, InfoPath ?? ???? ??????? ?????? ????? ?? ???? ?????

InfoPath 2010

??????? ???????? ?????, ?? ?? ??????? ???????? ??? ???? C# ???? ?? ??? ??? ????? ??? ???? ?? ???, ????? ????? ?? ???? ????:
  1. InfoPath ???????? 2010 ?? ??????? ?????
  2. ???????? ??????? ????????????????, ?? ??? ???????????, ?? ??? ????? ??????????? ????????
  3. ???? ??????? ???????? ???, ????? ??????????? ?? ??? ????.
  4. ???? ????????? ??????? ????? ??? ??????? ?? ?????? ?????, ????? Northwind.accdb ?? ??? ????, ?? ???? ???????.
  5. ????????? ?? ??? ??????? ????? ???, ???? ?? ???? ??????? ??????????????????? ???, ?? ???? ???????
  6. ????????? ???? ?? ???? ????? ?????? ??? ????? ??? ?????????????????:
    • ID
    • ?????
    • Last_Name
    • First_Name
    • Job_Title
    • Business_Phone
  7. ????? ????????.
  8. ????? ?????????? ???????? ??????? ???????? ?? ????? ???? ?? ????
  9. ???????????? ???? ??????? ????dataFields???, ?? ?? ?????? ??????d:Suppliers??? ?? ??????? ????? ???? ?? ????????? ???????? ????? ?????
  10. ?? ???? ??? ???, ????? ???? ?? ??? ???? ?? ????????? ?? ????? ??.
  11. ???????????? ???? ??????? ????queryFields???, ?? ?? ?????? ??????q: ???????????? ?? ??????? ????? ???? ?? ?????? ????????? ????? ????? (?? ???????? ??? ?? ???????? ?? ?????? ??.)
  12. ?? ???????????????? ??, ????? ????????.
  13. ??????????????? ??????????, ?? ?????????? ???????? ??? ????, ?? ??? ????C#, ?? ??? ????? ???????.

InfoPath 2007

??????? ???????? ?????? ??? ???? ?? ???, ????? ????? ?? ???? ????:
  1. InfoPath 2007 ?? ??????? ?????
  2. ???????? ??? ???? ??????? ????????? ????? ???, ????? ??????? ??????? ???????? ??????? ????.
  3. ?????? ??????? ???????? ??????? ????????? ???, ????? ?????????,?? ??? ????? ???????.
  4. ??????????? ??, ????? ???????? ???????, ?? ??? ????? ??????????. ??????? ???????????? ????? ???
  5. ??????? ???????????? ???, ????? ???? ?? ??? ??????? ??? ??????? ???????? ?????, ????? ???? ?? ??? ???????? ??????? ??????? ?????, ?? ??? ????? ????????.
  6. ????? ?? ??? ????? ????(Microsoft SQL ????? ??????? ?? ???? Microsoft Office Access)??? ?????, ?? ??? ????? ????????.
  7. ????? ??????????? ?? ??? ????.
  8. ???? ????????? ??????? ????? ??? ??????? ?? ?????? ?????, ?? ??????? ?? ??? ????, ?? ???? ???????.
  9. ????????? ?? ??? ?????? ??? ???? ????? ????? ???, ???? ?? ???? ?????????????????????? ???, ?? ???? ??????.
  10. ??????? ????? ??????????, ????????? ???? ?? ???? ????? ????? ???????? ????? ???:
    • ID
    • ?????
    • First_Name
    • Last_Name
    • Job_Title
    • Business_Phone
  11. ????? ????????.
  12. ????? ???????? ???? ???? ????? ??????? ????, ?? ????? ?????????? ???????? ????? ????? ???????? ?? ???? ?????? ?? ??? ?? ????? ?? ??? ???????? ????????
  13. ??????? ?????????? ???, ?? ??? ????? ????dataFields.
  14. ?? ????d:Suppliers??? ???? ?? ???????????? ??????? ???
  15. ?? ???? ????? ????, ?? ??????d:Suppliers?? ??? ??? ???????? ?? ????? ??.
  16. ??????????? ??, ????? ???????????? ???? ?????.
  17. ????????????? ??? ??, ????? ????????????????
  18. ??????????? ??, ????? ??????????? ??????.
  19. ?????????????, ????? ????????????????.
  20. ?????????? ???????? ??? ????????? ???, ????? ????C#, ?? ??? ????? ???????.

???? ????? ?????? ?? ???? ?? ??? ??????? ?????

?? ??? ????? ?? ?? ???? ??? ?? ???? ??? ???????? ?? ???? ??? ????? ???????? ???? ???? ??? ??????? ?? ??? ??? ???? ?? ???? ?? ???? ??? ??????? ?? ??? ??? ???? ?? ???, ?? ???? ??????????? ???? ???????? ????? ?? ???? ??? ?????? ????? SQL ?????? ???? ?? ??????????? ???? ???????? ?????? ????? ??? ????? ?? ???, ?? ??????? ??????????? ???? ??? ?????? ?? ?????? ???? ???? ???? ?? ?????? ?? InfoPath ??? ??? ?? ????

???? ????? ?????? ?? ????? ?? ??? ??????? ?? ????? ?? ????? ???????????? ?? InfoPath 2007 InfoPath 2010 ???, ?? ????? ?? ???? ????:

  1. ??????? ??? ???, ????-????? ?????????? ????????, ?? ???? ?????? ???.
  2. ????? ???????? ????:
    • ????????? ?????????????? ?? ??? ??? ?????? ?? ????? ???
    • ????????? ???????????? ?? ????????? ?????
    • ????????? ????ID???? ?? ???btnQuery
  3. ????? ??????????? ??? ??????? ???????????? ???? ????, ?? ?? ?????? ??????????? ?? ??? Visual Studio ??????? ?? ??????? ???? ?? ??? ??? ????? ????? BtnQuery "Clicked" ????? ?????? ??? ??????
  4. ??????? ????? "/ / ???? ???? ??? ???" ?????????? ??? ?? ???:
    //Create an XPathNavigator object for the main data source
    XPathNavigator xnMain = this.MainDataSource.CreateNavigator();
     
    //Create an AdoQueryConnection from the main data source by "casting" the default
    //data connection to an "AdoQueryConnection"
    AdoQueryConnection cn = (AdoQueryConnection)this.DataConnections["Main connection"];
     
    //Obtain the default SQL command for the form.
    string strOrigSQLCommand = cn.Command.ToString();
     
     
     
    // Obtain the query node that you want to change.
    XPathNavigator xnSuppliersQuery = xnMain.SelectSingleNode("/dfs:myFields/dfs:queryFields/q:Suppliers", this.NamespaceManager);
     
    //Obtain the text that was entered for the wildcard character search, and then clear the current query parameter so that InfoPath will leave the current query parameter blank.
    string strJobTitle = xnSuppliersQuery.SelectSingleNode("@Job_Title", this.NamespaceManager).Value;
    xnSuppliersQuery.SelectSingleNode("@Job_Title", this.NamespaceManager).SetValue(string.Empty);
     
    //Have InfoPath construct an SQL command that is based on all other field values.
    string strMySQLCommand = cn.BuildSqlFromXmlNodes(xnSuppliersQuery);
     
    //Save the other query items, and then clear the other query items before the next query.
    string strSupplierID = xnSuppliersQuery.SelectSingleNode("@ID", this.NamespaceManager).Value;
    xnSuppliersQuery.SelectSingleNode("@ID", this.NamespaceManager).SetValue(string.Empty);
    string strCompany = xnSuppliersQuery.SelectSingleNode("@Company", this.NamespaceManager).Value;
    xnSuppliersQuery.SelectSingleNode("@Company", this.NamespaceManager).SetValue(string.Empty);
    string strLastName = xnSuppliersQuery.SelectSingleNode("@Last_Name", this.NamespaceManager).Value;
    xnSuppliersQuery.SelectSingleNode("@Last_Name", this.NamespaceManager).SetValue(string.Empty);
    string strFirstName = xnSuppliersQuery.SelectSingleNode("@First_Name", this.NamespaceManager).Value;
    xnSuppliersQuery.SelectSingleNode("@First_Name", this.NamespaceManager).SetValue(string.Empty);
    string strBusPhone = xnSuppliersQuery.SelectSingleNode("@Business_Phone", this.NamespaceManager).Value;
    xnSuppliersQuery.SelectSingleNode("@Business_Phone", this.NamespaceManager).SetValue(string.Empty);
     
    //Add Job_Title to the query so that Job_Title can support wildcard characters.
    if (strJobTitle != string.Empty)
    {
           if (strMySQLCommand != string.Empty)
                  strMySQLCommand += " AND ";
     
           //Check whether the user entered the wildcard character (%) as part of the title.
    if(strJobTitle.Contains("%"))
                 strMySQLCommand += "[Job Title] LIKE '" + strJobTitle + "'";
           else
                 strMySQLCommand += "[Job Title] LIKE '" + strJobTitle + "%'";               
    }
     
    //Construct the full query string.
    string strSQLQuery = strOrigSQLCommand;
    if (strMySQLCommand != string.Empty)
    strSQLQuery += " WHERE " + strMySQLCommand;
     
    //Set the command and run the query.
    cn.Command = strSQLQuery;
    cn.Execute();
     
    //Restore all the user entries to the Query fields so that the user entries will 
    //be available if you want to change and to rerun the query.
    xnSuppliersQuery.SelectSingleNode("@ID", this.NamespaceManager).SetValue(strSupplierID);
    xnSuppliersQuery.SelectSingleNode("@Company", this.NamespaceManager).SetValue(strCompany);
    xnSuppliersQuery.SelectSingleNode("@Last_Name", this.NamespaceManager).SetValue(strLastName);
    xnSuppliersQuery.SelectSingleNode("@First_Name", this.NamespaceManager).SetValue(strFirstName);
    xnSuppliersQuery.SelectSingleNode("@Job_Title", this.NamespaceManager).SetValue(strJobTitle);
    xnSuppliersQuery.SelectSingleNode("@Business_Phone", this.NamespaceManager).SetValue(strBusPhone);
     
    //Restore the default table command (for the next time).
    cn.Command = strOrigSQLCommand;
     
    //Clean up
    xnMain = null;
    cn = null;
    xnSuppliersQuery = null;
  5. ????????? ????? ????? ????????????? ??? ????? ?? ?? ???? ?????????????????? ?? ???.
  6. ???????? ??????, ?? ?? InfoPath ??? ?????

??? ?? ??????? ????

????? ??? ?? ????? ????????? ??? ?????? ?????? ???? ?? ?? ??????????? ???? ????? ?? ??? ???? ???? ???????????? ??????????????????? ??? ?????? ???? ?????? ???????? %, ?????? ????? ???? ??? ?????? ??? ?????? ?????? ??? ???? ??????? ?? ??? ?????? ?? ??? ?? ?? ???????? ?? ?????????, ?? ??????? ?? ????? ?? ???? ???????? %. ?????? "??????" ??? ???? ???? ???????????? ??? ????????


??? ?????? ??? ?? ??? ?????? ??? ?????? ?????? ?????? ?? ???? ??? ???? ?? ???, ????? ????? ?? ???? ????:
  1. InfoPath 2010 ?? ???:????? ????????? ?? ??? ??, ????? ?????? ??????????? ????.
    InfoPath 2007 ?? ???:????? ????? ?? ????? ?????? ??????????? ????, ?? ??? ????? ???????????.
  2. ????? ???????????? ??????, ???????????? %.
  3. ????? ?????????? ??????

???? ????? ?????? ?????? ????? ?????? ?????? ?????? ?? ??? ?????? ???? ????

???

???? ID: 826992 - ????? ???????: 07 ????? 2011 - ??????: 3.0
???? ???? ???? ??:
  • Microsoft Office InfoPath 2007
  • Microsoft Office InfoPath 2003
??????: 
kbhowto kbmt KB826992 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:826992

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com