在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
我又试了试Delphi7,也是一样的错。 我想,BCB/Delphi的ADO是封装过了,会不会是封装得有问题? 于是跑到VB下写了个Demo,居然成功了~看来真的是封装的问题。 看来只有通过OLE直接操纵ADO了,写了段代码,试了试,也成功了 BCB代码如下:
1 void __fastcall TForm1::Button1Click(TObject *Sender)
2 { 3 const AnsiString sql = "SELECT * FROM Table WHERE ROWNUM <= 1"; 4 5 Variant Conn; 6 Variant ResultSet; 7 Variant ResultField; 8 Variant Size, Value; 9 10 Conn = Variant::CreateObject("adodb.connection"); 11 Conn.OlePropertySet("Provider", "OraOLEDB.Oracle"); 12 Conn.OleFunction("Open", "Database", "UserName", "Password"); 13 14 ResultSet = Variant::CreateObject("adodb.recordset"); 15 ResultSet.OleFunction("Open", sql, Conn, 0, 1); 16 ResultField = ResultSet.OlePropertyGet("Fields", "FieldNameOrIndex"); 17 Size = ResultField.OlePropertyGet("ActualSize"); 18 Value = ResultField.OleFunction("GetChunk", Size); 19 20 void* Data = NULL; 21 SafeArrayAccessData(Value.parray, &Data); 22 try 23 { 24 TFileStream* Stream = new TFileStream("C:\\blob.txt", fmCreate); 25 try 26 { 27 Stream->Write(Data, Size); 28 } __finally { 29 delete Stream; 30 } 31 } __finally { 32 SafeArrayUnaccessData(Value.parray); 33 } 34 } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论