functor
July 12th, 2005, 04:52 PM
Hey...
I've got a stored procedure on a MS SQL db that returns a binary value. It's 15 bytes of hex deta that i need to decode once I get it from the DB. The problem is that when i get it from the DB, it just shows up as a string of "System.Byte[]" and I can't figure out how to get to the actual binary data.
Here is my code:
OdbcConnection *myCon = new OdbcConnection("Driver={Sql Server};server=localhost;trusted_connection=yes;database=Test;");
try{
myCon->Open();
OdbcCommand *myCmd = new OdbcCommand("{call ccGetCards}",myCon);
OdbcDataReader *myReader = myCmd->ExecuteReader();
while (myReader->Read())
{
//Binary data is in the 3rd field of the result set
Console::WriteLine(myReader->GetValue(2)->ToString());
}
myReader->Close();
}
catch(OdbcException *myEx)
{
for (int i=0;i<myEx->Errors->Count;i++)
{
Console::WriteLine(myEx->Errors->Item[i]->Source,myEx->Errors->Item[i]->Message);
}
}
myCon->Close();
How can I get to the real data? Please help!
I've got a stored procedure on a MS SQL db that returns a binary value. It's 15 bytes of hex deta that i need to decode once I get it from the DB. The problem is that when i get it from the DB, it just shows up as a string of "System.Byte[]" and I can't figure out how to get to the actual binary data.
Here is my code:
OdbcConnection *myCon = new OdbcConnection("Driver={Sql Server};server=localhost;trusted_connection=yes;database=Test;");
try{
myCon->Open();
OdbcCommand *myCmd = new OdbcCommand("{call ccGetCards}",myCon);
OdbcDataReader *myReader = myCmd->ExecuteReader();
while (myReader->Read())
{
//Binary data is in the 3rd field of the result set
Console::WriteLine(myReader->GetValue(2)->ToString());
}
myReader->Close();
}
catch(OdbcException *myEx)
{
for (int i=0;i<myEx->Errors->Count;i++)
{
Console::WriteLine(myEx->Errors->Item[i]->Source,myEx->Errors->Item[i]->Message);
}
}
myCon->Close();
How can I get to the real data? Please help!