Experiencing issues trying to execute a particular SmartObject method.

  • 25 November 2008
  • 4 replies
  • 0 views

Badge +3

Given that I have the attached SmartObject (that has been deployed) with the following schema:
Name: DB2
  Method: GetStopCodes


With the following code:

private static string getStopCodesForPolicy(string PolicyNumber)
{
string retStopCodesForPolicy = string.Empty;

using (SOConnection soConn = new SOConnection("Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Server=txs9312137;Port=5555"))
{
soConn.Open();

string soQuery = "SELECT * FROM DB2.GetStopCodes WHERE POL_NBR_TXT='" + PolicyNumber+"'";
using (SOCommand soCmd = new SOCommand(soQuery, soConn))
{
soCmd.CommandType = CommandType.Text;

using (SODataAdapter soDA = new SODataAdapter(soCmd))
{
soDA.AcceptChangesDuringFill = true;
soDA.FillLoadOption = LoadOption.OverwriteChanges;
using (DataSet ds = new DataSet())
{
soDA.Fill(ds, "Results");

if (ds.Tables[0].Rows.Count > 0)
{
string[] stopCodes = new string[ds.Tables[0].Rows.Count];
for (int index = 0; index < stopCodes.Length; index++)
{
DataRow dr = ds.Tables[0].Rows[index];
stopCodes[index] = dr["POL_STOP_CD"].ToString();
}

retStopCodesForPolicy = string.Join(",", stopCodes);
}
}
}
}
}
return retStopCodesForPolicy;
}

I am receiving an error on the soDA.Fill(ds, "Results"); line of "Invalid SmartMethod name 'GetStopCodes' for SmartObject with name 'DB2'."


Can anyone tell me why? (I'm using 0803)


Thanks!


11039iAB1CF27BA5D413A3.png

4 replies

Badge
Check the .sodx file.  It may have been named differently than you expected.  If you rename a method it will just change the display name and not the original name when the method was created.
Badge +3
Thanks, Tom.  You were correct.  It should also be noted that if your original name had spaces in it, they will have been replaced with underscores. 
Badge +3
One major caveat to anyone using the code above... If the source table is large, you're going to get Out Of Memory Exceptions as it appears the ado.net provider for smartobjects brings back the entire resultset and filters on the server instead of the database.  I have now re-written (taken what I learned about the smartobject method naming conventions) using the normal smartobject api and it works wonderfully.
Badge +3
Mathew, to make sure the Out of Memory exception isn't being thrown by the DB2 client provider I'm using, I wrote a quick test harness to pull back every row in the table (all 46,594 of them) which it did successfully.  So the error definitely comes from K2's ado.net provider layer for SmartObjects.  As far as the number of records it takes to create the error, I couldn't tell you.  I know 46,594 is too much for it :)  but that's all I know.  If you're returning a large result set, I'd say use something or else altogether or leverage the SO API as opposed to the ado.net provider.

Reply