Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

getBlob VC++ compile error (1 reply)

$
0
0
Hi:

I have had success with the C++ connector in writing and reading data to a database, but I am unable to put together code to get a blob. My current attempt does not compile, and I've been unable to find a C++ example from the internet though there are many for Java. I am currently trying to figure out the complexities of the stream objects, but can anyone help me implement the routine below to load a blob? I have code that writes blob data that complies but I have not yet tried to run it. Thanks in advance.

I am using MS VC++ Express 2008

Error:
======

1>c:\users\mike\documents\testengineer\coding\dev\modules_c++_express_2008\simple_mysqlcon\simple_mysqlconn\simple_mysqlcon.cpp(91) : error C2664: 'std::basic_istream<_Elem,_Traits>::basic_istream(std::basic_streambuf<_Elem,_Traits> *,bool)' : cannot convert parameter 1 from 'std::istream *' to 'std::basic_streambuf<_Elem,_Traits> *'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Code:
=====

Just the snippet of where the problem is. I can provide the complete code.

int loadBlob (DB_key key)
{
if(!pDB_Conn) return -1;

int iRet = 0;
char szBuf[256] = {'\0'}; // 512

sql::Statement *stmt=NULL;
sql::ResultSet *res=NULL;

try
{

stmt = pDB_Conn->createStatement();
sprintf(szBuf,"SELECT MY_TABLE_BLOB FROM MY_TABLE WHERE ID = %u;",key);

res = stmt->executeQuery(szBuf);

if (res->rowsCount()!=0)
{
res->next();

std::istream blobIn(res->getBlob("MY_TABLE_BLOB"));

string s;

int count=0;
while (getline(blobIn, s))
{
strcpy(gszArray[count],s.c_str());

if(++count == 256) break;
}
}
else
iRet = -1;

} catch (sql::SQLException &e) {

iRet = -1;
}

if(stmt) delete stmt;
if(res) delete res;

return iRet;

}

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>