mbewers980
06-12-2009, 05:09 AM
Good morning
This method was definitely working for me before and I can't seem to find out what I've changed that makes it return the following error when running my application now:
public DataTable SearchDefault(string searchItem, string criteria)
{
using (OracleConnection oce = new OracleConnection(ConnectionString))
{
oce.Open();
DataTable ds = new DataTable();
OracleCommand command = oce.CreateCommand();
command.CommandType = CommandType.Text;
string queryString =
string.Format(@"SELECT corporateactionnumber, sedolnumber,
isincode, stockname, corporateactiontype, receiveddate, admincode,
signedoff, effectivedate, paymentdate, agentdeadlinedate, customerdeadline,
ratio1, ccy, price, newname, terms, diarynotes
FROM tblcorporateactions
WHERE {0} = {1}", searchItem, criteria);
command.CommandText = queryString;
command.Prepare();
OracleDataAdapter productsAdapter = new OracleDataAdapter(command);
productsAdapter.Fill(ds);
return ds;
}
As you can see, I'm passing in 2 statements to the where clause in my select statement but, every time this method is run, nothing is returned and my program throws an exception.
When I changed the Exception type in my try/catch clause of thw eeb page which is calling this method, I got an: 'Oracle Error: Unable to cast object of type' message, but yet I'm not trying to cast anything, I'm simple returning a table of results.
Any help would be appreciated!
Thanks
Matt
This method was definitely working for me before and I can't seem to find out what I've changed that makes it return the following error when running my application now:
public DataTable SearchDefault(string searchItem, string criteria)
{
using (OracleConnection oce = new OracleConnection(ConnectionString))
{
oce.Open();
DataTable ds = new DataTable();
OracleCommand command = oce.CreateCommand();
command.CommandType = CommandType.Text;
string queryString =
string.Format(@"SELECT corporateactionnumber, sedolnumber,
isincode, stockname, corporateactiontype, receiveddate, admincode,
signedoff, effectivedate, paymentdate, agentdeadlinedate, customerdeadline,
ratio1, ccy, price, newname, terms, diarynotes
FROM tblcorporateactions
WHERE {0} = {1}", searchItem, criteria);
command.CommandText = queryString;
command.Prepare();
OracleDataAdapter productsAdapter = new OracleDataAdapter(command);
productsAdapter.Fill(ds);
return ds;
}
As you can see, I'm passing in 2 statements to the where clause in my select statement but, every time this method is run, nothing is returned and my program throws an exception.
When I changed the Exception type in my try/catch clause of thw eeb page which is calling this method, I got an: 'Oracle Error: Unable to cast object of type' message, but yet I'm not trying to cast anything, I'm simple returning a table of results.
Any help would be appreciated!
Thanks
Matt