 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Angel Guest
|
Posted: Mon Jul 04, 2005 10:39 am Post subject: Import ADO type library |
|
|
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.
|
|
| Back to top |
|
 |
Angel Guest
|
Posted: Mon Jul 04, 2005 11:24 am Post subject: Re: Import ADO type library |
|
|
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:
| Quote: | 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.
|
|
|
| Back to top |
|
 |
Viatcheslav V. Vassiliev Guest
|
Posted: Tue Jul 05, 2005 10:08 am Post subject: Re: Import ADO type library |
|
|
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 (AT) example (DOT) net> ???????/???????? ? ???????? ?????????:
news:42c91c7d$1 (AT) newsgroups (DOT) borland.com...
| Quote: | 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.
|
|
|
| Back to top |
|
 |
Angel Guest
|
Posted: Tue Jul 05, 2005 2:00 pm Post subject: Re: Import ADO type library |
|
|
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:
| Quote: | 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)
|
|
|
| Back to top |
|
 |
Viatcheslav V. Vassiliev Guest
|
Posted: Tue Jul 05, 2005 8:48 pm Post subject: Re: Import ADO type library |
|
|
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 (AT) example (DOT) net> ???????/???????? ? ???????? ?????????:
news:42ca92bc$1 (AT) newsgroups (DOT) borland.com...
| Quote: | 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)
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|