Infopath Wildcard Function

K

KayZee

Hello,

I am trying to build this application where I will be using wildcards, but I
am coming to a dead end when I try to modify the code that I found on the
Help and Support page
(http://support.microsoft.com/default.aspx?scid=kb;EN-US;826992). The error
message that I am getting is that whatever I type into the field I want to do
a wildcard search in, I get a message that says the typed word is an INVALID
COLUMN. I don't even think it should recognize it as a column. Does anyone
have an idea what is going on? Here are some parts of the code without
getting too deep into it...


// Get the default SQL command for the form.
var strOrigSQLCommand = XDocument.QueryAdapter.Command;

// Get the query node that you want to modify.
var querytbl_____ = XDocument.DOM.selectSingleNode(
"/dfs:myFields/dfs:queryFields/q:tbl_______");

var strTitle = querytbl_______.selectSingleNode("@___Title").text;
querytbl______.selectSingleNode("@____Title").text = "";

.......

if (strTitle != "")
{
if (strMySQLCommand != "")
strMySQLCommand = strMySQLCommand + " AND ";

strMySQLCommand = strMySQLCommand +
"([tbl______].[________Title] LIKE \"" + strTitle + "\")";
}


// Construct the full query string.
var strSQLQuery = strOrigSQLCommand;
if (strMySQLCommand != "")
strSQLQuery = strSQLQuery + " WHERE " + strMySQLCommand;

// This is the query.
XDocument.UI.Alert(strSQLQuery);

// Run the query.
XDocument.QueryAdapter.Command = strSQLQuery;
XDocument.Query();


Thanks for all your help
 
M

Michelle

Hi KayZee

Are you connecting to an Access DB or SQL Server DB? The example at
the support page is for an Access DB so the SQL query expects values
to be inside double quotes "".

SQL Server handles query string a little differently and considers
anything in double quotes to be columns. Instead SQL Server expects
string values to be inside single quotes ''.

Michelle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top