Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specified cast is not valid

Status
Not open for further replies.

CrossofIron

Programmer
Nov 27, 2006
3
AZ
Hello.
i have a problem with datareader
when i run it i get
'Specified cast is not valid ' error

string str = "select max(substr(type,instr(TYPE,'/')+1,length(type)))+1 result from DOCUMENTTYPES where type like 'DCO%'";
dOCTINCTYPETextBox.Text = DataBase.GetDataReader(str).GetString(0);

but afther changing it to this:
string str = "select max(TYPE) result from DOCUMENTTYPES where type like 'DCO%'";
dOCTINCTYPETextBox.Text = DataBase.GetDataReader(str).GetString(0);

it works without problem ,i don't know why?
but if run this query in toad it works without problem

select max(substr(type,instr(TYPE,'/')+1,length(type)))+1 result from DOCUMENTTYPES where type like 'DCO%'

help me please
thanks in advance
 
try this

DataBase.GetDataReader(str).Item(0).ToString;

What value should the first statement be returning?

What value should the second be returning?




Christiaan Baes
Belgium

"My new site" - Me
 
there is no 'Item' of reader
i used GetDataTypeName to see return type
1)returns decimal
2)varchar2
i used to_char to convert result to char, it worked with GetString(0)
but can i return an universal result from all field types of query?(not use data conversion)
 
Sorry it must have been

DataBase.GetDataReader(str).getItem(0).ToString;


GetItem returns an object wich you can cast.



Christiaan Baes
Belgium

"My new site" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top