哪位大侠知道:如何用 MySql++ 存取 Blob 字段啊?就是二进制字段,最好给个例子,不胜感激。。。

HackerJLY 2013-01-29 09:56:20
哪位大侠知道:如何用 MySql++ 存取 Blob 字段啊?就是二进制字段,最好给个例子,不胜感激。。。
...全文
228 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
HackerJLY 2013-01-30
  • 打赏
  • 举报
回复
读取搞定了

void CprjMySqlPlusPlusTestDlg::OnBnClickedbtnbinaryread()
{
	// TODO: 在此添加控件通知处理程序代码
	
	CString strTemp;

	mysqlpp::Connection ConnectionThis;

	bool bReturn = false;

	CString strMsg;

	size_t i;

	size_t j;

	char * pchar = NULL;

	const char * pconstchar = NULL;

	WCHAR * pwchar = NULL;

	string stringTemp;
	
	ostringstream ostringstreamThis;

	Face FaceThis;

	int iId = 0;

	int iLength = 0;

	void * pvoid = NULL;

	mysqlpp::sql_blob_null sql_blob_null_This;

	structTest structTestThis;
	//==================================================================================================


	//--------------------------------------------------------------------------------------------------
	// Connect to the sample database.

	bReturn = ConnectionThis.connect("world", "localhost", "root", "root");
	//ConnectionThis.
	if (!bReturn) 
	{
		strTemp = ConnectionThis.error();
		strMsg.Format(L"ConnectionThis.connect failed : %s", strTemp);
		MessageBox(strMsg);
		return;
	}

	m_strInfo.Empty();

	// Retrieve a subset of the sample stock table set up by resetdb
	
	mysqlpp::Query QueryThis = ConnectionThis.query();

	QueryThis << "SELECT * FROM FACE_LOG WHERE LOG_ID = 20";
	
	mysqlpp::StoreQueryResult StoreQueryResultThis = QueryThis.store();
	
	if(!StoreQueryResultThis)
	{
		strTemp = QueryThis.error();
		strMsg.Format(L"QueryThis.store failed : %s", strTemp);
		MessageBox(strMsg);
		return;
	}

	sql_blob_null_This = StoreQueryResultThis[i][1];

	iLength = sql_blob_null_This.data.length();

	pconstchar = (const char *)sql_blob_null_This.data.data();

	memcpy(&structTestThis, pconstchar, iLength);

	return;
}
HackerJLY 2013-01-29
  • 打赏
  • 举报
回复
上面写错了,写入的我好像已经搞定了,想知道读取的
HackerJLY 2013-01-29
  • 打赏
  • 举报
回复
引用 1 楼 rucypli 的回复:
百度很多啊 http://www.cnblogs.com/haichang/archive/2011/04/03/2004359.html
这个文章好像只有写入,没有读取 读取的我好像已经搞定了,用的其他方式,和这个文章里的不一样,不知道我用的那种的方式是否支持长数据 我想知道如何读取
rucypli 2013-01-29
  • 打赏
  • 举报
回复

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧