K
Kevin Changet
IP 2003, Jscript, Custom Submit code, Main Data Connection connected to 1
simple SQL Server table. Table has two columns, DI_NUM and SHIP_SD_NUM,
SHIP_SD_NUM is the Primary Key.
On my custom submit, I'd like to query the SQL Table and see if the Primary
key arleady exists in the table by adding a a condition like "Where
SHIP_SD_NUM = '123456'". If so, throw up an error message, if not, process
the submit.
I'm having problems getting IP to let me know if the primary key already
exists in the table. I would think this is possible, and am maybe missing
something obvious, but am pretty much stuck.
Code snippets as follows:
var origCommand = XDocument.DataAdapters["Main connection"].Command;
var objMainDataAdapter = XDocument.DataAdapters["Main connection"];
var strSHIP_SD_NUM = "123456";
objMainDataAdapter.Command = "select count(*) as Expr1 from CUSTOMER_PROFILE
where SHIP_SD_NUM = '" + strSHIP_SD_NUM + "'";
What I've tried:
1) ? objMainDataAdapter.Command
"select count(*) as Expr1 from CUSTOMER_PROFILE where SHIP_SD_NUM = '123456'"
? objMainDataAdapter.Query()
The query method on the Document object failed.
InfoPath cannot run the specified query. No query fields have been
generated because the specified SQL statement is too complex for InfoPath to
parse.
1b) I get the feeling that IP doesn't like the "count(*)" portion and that
my XML Schema isn't set up to accept that...ok...change tactics to return a
row of data.
2) objMainDataAdapter.Command = "select \"DI_NUM\", \"SHIP_SD_NUM\" from
\"dbo\".\"CUSTOMER_PROFILE\" where \"SHIP_SD_NUM\" = \'123456\'"
? objMainDataAdapter.Query()
undefined
Any suggestions appreciated, I'm open to any solution (short of creating a
secondary data connection/web service as I know how to pursue these avenues
already).
simple SQL Server table. Table has two columns, DI_NUM and SHIP_SD_NUM,
SHIP_SD_NUM is the Primary Key.
On my custom submit, I'd like to query the SQL Table and see if the Primary
key arleady exists in the table by adding a a condition like "Where
SHIP_SD_NUM = '123456'". If so, throw up an error message, if not, process
the submit.
I'm having problems getting IP to let me know if the primary key already
exists in the table. I would think this is possible, and am maybe missing
something obvious, but am pretty much stuck.
Code snippets as follows:
var origCommand = XDocument.DataAdapters["Main connection"].Command;
var objMainDataAdapter = XDocument.DataAdapters["Main connection"];
var strSHIP_SD_NUM = "123456";
objMainDataAdapter.Command = "select count(*) as Expr1 from CUSTOMER_PROFILE
where SHIP_SD_NUM = '" + strSHIP_SD_NUM + "'";
What I've tried:
1) ? objMainDataAdapter.Command
"select count(*) as Expr1 from CUSTOMER_PROFILE where SHIP_SD_NUM = '123456'"
? objMainDataAdapter.Query()
The query method on the Document object failed.
InfoPath cannot run the specified query. No query fields have been
generated because the specified SQL statement is too complex for InfoPath to
parse.
1b) I get the feeling that IP doesn't like the "count(*)" portion and that
my XML Schema isn't set up to accept that...ok...change tactics to return a
row of data.
2) objMainDataAdapter.Command = "select \"DI_NUM\", \"SHIP_SD_NUM\" from
\"dbo\".\"CUSTOMER_PROFILE\" where \"SHIP_SD_NUM\" = \'123456\'"
? objMainDataAdapter.Query()
undefined
Any suggestions appreciated, I'm open to any solution (short of creating a
secondary data connection/web service as I know how to pursue these avenues
already).