Thread View: borland.public.cppbuilder.database.ado
5 messages
5 total messages
Started by Angel
Mon, 04 Jul 2005 10:39
Import ADO type library
Author: Angel
Date: Mon, 04 Jul 2005 10:39
Date: Mon, 04 Jul 2005 10:39
61 lines
2581 bytes
2581 bytes
Hello to all.
(BCB6 Enterprise)
I have imported the Microsoft ActiveX Data Objects 2.8 Library, because
i have to make an application that doesn't use ADOExpress.
I use the imported objects in this function:
HRESULT __fastcall ADODatabase::ExecuteCmd(wchar_t* CmdStr,VARIANT* pParams)
{
HRESULT hr = -1;
ConnectionPtr DBConn;
CommandPtr DBCommand;
RecordsetPtr RecTemp;
try
{
hr=DBConn.CreateInstance(CLSID_Connection);
if(SUCCEEDED(hr))
{
RecTemp.CreateInstance(CLSID_Recordset);
hr = pDBCommand.CreateInstance(CLSID_Command);
if(SUCCEEDED(hr))
{
DBCommand->CommandText = CmdStr;
DBCommand->ActiveConnection = DBConn;
RecTemp = DBCommand->Execute( TVariantInParam(1),
Params,
adCmdText);
}
}
}
catch(...)
{
hr = -1;
}
return hr;
}
but I always get a compiling error ('CommandText is not accessible').
I have edited the ADODB_TLB.h file, changing the lines where the
property CommandText is defined to define the write part of the property
in this way:
__property BSTR CommandText = {read = get_CommandText};
//original line
__property BSTR CommandText = {read = get_CommandText
write = put_CommandText}; //Line modified by me
but I cannot get the command to work
I think that Tlibimp is buggy, and also is the Import type library
option of the menu.
Any suggestion? I repeat that i cannot use ADOExpress.
Thanks in advance.
Re: Import ADO type library
Author: Angel
Date: Mon, 04 Jul 2005 11:24
Date: Mon, 04 Jul 2005 11:24
77 lines
3233 bytes
3233 bytes
I forgot to say that the connection is opened correctly (forgot to put
the line in the sample code that I posted), and that I have trouble only
with the Command object. The Recordset object has worked fine for me in
other functions.
When I execute the command, after I have modified the CommandText
property, it is always empty (the commandtext property) and I get an
error (0x80040E0C-Empty commandtext) when I execute the command .
Thanks again.
Angel wrote:
> Hello to all.
>
> (BCB6 Enterprise)
>
> I have imported the Microsoft ActiveX Data Objects 2.8 Library, because
> i have to make an application that doesn't use ADOExpress.
>
> I use the imported objects in this function:
>
> HRESULT __fastcall ADODatabase::ExecuteCmd(wchar_t* CmdStr,VARIANT*
> pParams)
> {
> HRESULT hr = -1;
> ConnectionPtr DBConn;
> CommandPtr DBCommand;
> RecordsetPtr RecTemp;
>
> try
> {
> hr=DBConn.CreateInstance(CLSID_Connection);
> if(SUCCEEDED(hr))
> {
> RecTemp.CreateInstance(CLSID_Recordset);
> hr = pDBCommand.CreateInstance(CLSID_Command);
> if(SUCCEEDED(hr))
> {
> DBCommand->CommandText = CmdStr;
> DBCommand->ActiveConnection = DBConn;
> RecTemp = DBCommand->Execute( TVariantInParam(1),
> Params,
> adCmdText);
> }
>
> }
> }
>
> catch(...)
> {
> hr = -1;
> }
> return hr;
> }
>
> but I always get a compiling error ('CommandText is not accessible').
>
> I have edited the ADODB_TLB.h file, changing the lines where the
> property CommandText is defined to define the write part of the property
> in this way:
>
> __property BSTR CommandText = {read = get_CommandText};
> //original line
> __property BSTR CommandText = {read = get_CommandText
> write = put_CommandText}; //Line modified by me
>
> but I cannot get the command to work
>
> I think that Tlibimp is buggy, and also is the Import type library
> option of the menu.
>
> Any suggestion? I repeat that i cannot use ADOExpress.
>
> Thanks in advance.
Re: Import ADO type library
Author: Viatcheslav V. Vassiliev
Date: Tue, 05 Jul 2005 10:08
Date: Tue, 05 Jul 2005 10:08
94 lines
3810 bytes
3810 bytes
Try
DBCommand->CommandText = WideString(CmdStr);
break on next line and look what is in CommandText. Does it work for command
without parameters?
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Angel" <user@example.net> ???????/???????? ? ???????? ?????????:
news:42c91c7d$1@newsgroups.borland.com...
>I forgot to say that the connection is opened correctly (forgot to put the
>line in the sample code that I posted), and that I have trouble only with
>the Command object. The Recordset object has worked fine for me in other
>functions.
>
> When I execute the command, after I have modified the CommandText
> property, it is always empty (the commandtext property) and I get an error
> (0x80040E0C-Empty commandtext) when I execute the command .
>
> Thanks again.
>
>
>
> Angel wrote:
>
>> Hello to all.
>>
>> (BCB6 Enterprise)
>>
>> I have imported the Microsoft ActiveX Data Objects 2.8 Library, because i
>> have to make an application that doesn't use ADOExpress.
>>
>> I use the imported objects in this function:
>>
>> HRESULT __fastcall ADODatabase::ExecuteCmd(wchar_t* CmdStr,VARIANT*
>> pParams)
>> {
>> HRESULT hr = -1;
>> ConnectionPtr DBConn;
>> CommandPtr DBCommand;
>> RecordsetPtr RecTemp;
>>
>> try
>> {
>> hr=DBConn.CreateInstance(CLSID_Connection);
>> if(SUCCEEDED(hr))
>> {
>> RecTemp.CreateInstance(CLSID_Recordset);
>> hr = pDBCommand.CreateInstance(CLSID_Command);
>> if(SUCCEEDED(hr))
>> {
>> DBCommand->CommandText = CmdStr;
>> DBCommand->ActiveConnection = DBConn;
>> RecTemp = DBCommand->Execute( TVariantInParam(1),
>> Params,
>> adCmdText);
>> }
>>
>> }
>> }
>>
>> catch(...)
>> {
>> hr = -1;
>> }
>> return hr;
>> }
>>
>> but I always get a compiling error ('CommandText is not accessible').
>>
>> I have edited the ADODB_TLB.h file, changing the lines where the property
>> CommandText is defined to define the write part of the property in this
>> way:
>>
>> __property BSTR CommandText = {read = get_CommandText};
>> //original line
>> __property BSTR CommandText = {read = get_CommandText
>> write = put_CommandText}; //Line modified by me
>>
>> but I cannot get the command to work
>>
>> I think that Tlibimp is buggy, and also is the Import type library option
>> of the menu.
>>
>> Any suggestion? I repeat that i cannot use ADOExpress.
>>
>> Thanks in advance.
Re: Import ADO type library
Author: Angel
Date: Tue, 05 Jul 2005 14:00
Date: Tue, 05 Jul 2005 14:00
23 lines
1691 bytes
1691 bytes
It works!!! Why??? I don't understand. I did try casting CmdStr to BSTR and it didn't work. Anyway, thank you very much. Viatcheslav V. Vassiliev wrote: > Try > > DBCommand->CommandText = WideString(CmdStr); > > break on next line and look what is in CommandText. Does it work for command > without parameters? > > //------------------------------------------ > Regards, > Vassiliev V. V. > http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + > ADO.Net > http://www.oledbdirect.com - The fastest way to access MS SQL Server, > MS Jet (Access) and Interbase (through OLEDB) >
Re: Import ADO type library
Author: Viatcheslav V. Vassiliev
Date: Tue, 05 Jul 2005 20:48
Date: Tue, 05 Jul 2005 20:48
40 lines
2457 bytes
2457 bytes
C++ Builder has some problems with assigning WideString properties, mostly C++ Builder 5 or previous, in C++ Builder 6 it is solved, but anyway it is safer to assign exactly WideString to property with type WideString. As I understand, sometimes C++ Builder uses incorrect constructor for WideString (or BSTR), for example, with char* (not wchar_t*) as parameter, but here I may be wrong. //------------------------------------------ Regards, Vassiliev V. V. http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + ADO.Net http://www.oledbdirect.com - The fastest way to access MS SQL Server, MS Jet (Access) and Interbase (through OLEDB) "Angel" <user@example.net> ???????/???????? ? ???????? ?????????: news:42ca92bc$1@newsgroups.borland.com... > It works!!! Why??? I don't understand. I did try casting CmdStr to BSTR > and it didn't work. > > Anyway, thank you very much. > > > Viatcheslav V. Vassiliev wrote: > >> Try >> >> DBCommand->CommandText = WideString(CmdStr); >> >> break on next line and look what is in CommandText. Does it work for >> command without parameters? >> >> //------------------------------------------ >> Regards, >> Vassiliev V. V. >> http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + >> ADO.Net >> http://www.oledbdirect.com - The fastest way to access MS SQL Server, >> MS Jet (Access) and Interbase (through OLEDB) >>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads