pclarke7
asked on
Returning values to variables from a c# SQL statement
Hello,
I have a C# application which uses an ODBC connection to access data from a DB2 database. Typical SQL statement(s) would be
"Select field2, field4, field10 from ItemMaster where field1 = '12345678' "
I would like to be able to return these 3 file values (field2, field4 & field10) to variables defined within the application. Appreciate any pointers as to how I might achieve this.
regards
Pat
I have a C# application which uses an ODBC connection to access data from a DB2 database. Typical SQL statement(s) would be
"Select field2, field4, field10 from ItemMaster where field1 = '12345678' "
I would like to be able to return these 3 file values (field2, field4 & field10) to variables defined within the application. Appreciate any pointers as to how I might achieve this.
regards
Pat
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
If so:
I assume you are doing something like this:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.dndp.doc/htm/frlrfIBMDataDB2DB2DataReaderClassTopic.htm
So take a look at this section:
Open in new window
You get the data via:
myReader.GetSomething(Inde
Example:
Int32 i = myReader.GetInt32(0)
This would get the first field into an int treating it as such or cause an error if field 0 is a string.