[问题] 谁能稍微讲解一下如何通过ADO把一串binary塞到数据库里头呢

苦逼热狗

路边通讯社社长
VIP
注册
2002-10-12
消息
47,114
荣誉分数
2,376
声望点数
393
我花了不下12小时,几乎尝试了网上所有有关这一类的文章,可是没有一次成功的
在读取commands的时候没有任何数据,清一色的NULL;

----------------
问题解决 不过如果有好心的朋友讲解一下最好了
----------------
 
weird, 我直接用查询分析器查询的话发现commands里头其实是有东西的
说明我的ReadData有问题
 
well for ADO.NET yes, its a good source to learn, and there are tons of tutorial/sample code i can grab and use.
the problem is i am still using VC6/ADO1.5. :)
 
I wrote one about a year ago using ADO:

when writing to database, open the recordset, call AppendNew to create a new record, then call Recordset::GetField to get the field object, call Field::AppendChunk repeatedly to set the binary data, and finally call Recordset::UpdateBatch to save data into database.

when reading from database, get the recordset object first, then call Recordset::GetField to get field object, and call Field::GetChunk repeatedly to read data.
 
you forgot to mention it has to be safearray
 
塞成string行不行啊,用的时候再convert回来
 
time critical的东西(网游),我需要尽可能的减少数据的改变与传送
btw,从来不用string
char *,wchar_t*就够了
用之前GlobalAlloc,用完直接GlobalFree
很多时候能用系统自带的API的话我不会用MFC一类带的函数

此外这个case比较恶心的地方就是
客户端发送的是byte, byte, integer, byte, wchar_t*
而服务器端需要保存这个格式,然后返回所有对应用户id的所有保存过的数据
所以我才会想要直接把socket里头的buff内容直接存入数据库

之前是想过
wsprintfW(szBuffer, L"%d,%d,%d,%d,%s" byte1,byte2,integer1,byte3,widecharstring);
然后再用swscanf(szBuffer, "%d,%d,%d,%d,%s", &byte1,&byte2,&integer1,&byte3,&widecharstring);
读出来
可是因为我们需要的是速度和数据的正确性,binary array更合适点
 
最初由 闷骚王中王 发布
time critical的东西(网游),我需要尽可能的减少数据的改变与传送
btw,从来不用string
char *,wchar_t*就够了
用之前GlobalAlloc,用完直接GlobalFree
很多时候能用系统自带的API的话我不会用MFC一类带的函数

此外这个case比较恶心的地方就是
客户端发送的是byte, byte, integer, byte, wchar_t*
而服务器端需要保存这个格式,然后返回所有对应用户id的所有保存过的数据
所以我才会想要直接把socket里头的buff内容直接存入数据库
你数据库要存binary data的field是什么类型?
 
最初由 胖蹄阿克 发布

你数据库要存binary data的field是什么类型?
最后改成image了,然后我忘了我在code里头动啥地方了,就突然可以用了,我当时就疯了
 
后退
顶部