|
Here we have a Custom OLEDB provider. We have problems
dealing with the null values. The OLEDB provider is in
VC. Here we get the records as an variant array and
then moving it to a stream object and then assigning
it to a BSTR pointer. We are reading that as an ADO
recordset from VB. All the values are ok in VB. But
when we come across null values, we are not able to
process it properly. When we write NULL to the stream
object (which is bytes), we are reading it as 0 in the
VB recordset.(since in vc NULL has a value 0). So i need to read that value as null in
the VB.
In VC i tried writing VT_NULL and VT_EMPTY. But i
could not read that as null in VB.
if i use the isnull(fieldname) , i need to get the
result as true if the value is null. I dont know how
the null value is treated internally.
We use this OLEDB provider not only from VB, we use
even from Crystal reports for reports.
So can anybody please let me know how do it or let me
know any source where i can get the help from.
|
|
|
|
|
Hi,
I have Q concerning ADO/OLEDB.
I am writing an application which has to access MS-Access databases selected
at runtime by the user thru a file open dialog, the format of the data bases
is same but the databases may be located in different places.
1. Can I use ADO/OLEDB to open these DB's when a path is specified
( This capability like that of DAO, the path can be spec and
opened )
2. Or do i need the DSN and not specify the actual location
so that the DSN will ask the user to locate the DB.
(Actually here the application will use ODBC again when i want to
use ADO)
Since you are already working in OLEDB I hope you can help me in
this context.
Any suggestions or awnsers will be helpful.
|
|
|
|
|
Do you set the DBSTATUS_S_ISNULL in the status field for the accessor in your custom OLEDB provider??? I guess that is why VB does not cosider it as NULL properly.
|
|
|
|
|
Hi,
I'm new to COM and ATL and was wondering why do I need another set of windowing classes for COM development since i can easily embed MFC code (tried only for dialogs so far though, maybe i cannot do everything?)
Thanks
|
|
|
|
|
Hello everyone.
This is my first ATL/COM project, and I think the progress is "behaving" so far (happy to be one week behind the deadline). However, there is one dead-end issue that I cannot resolve:
Within my ATL component, I have to use a couple of in-proc Visual Basic - based COM .dll's. I use #import "XXXX.dll" in my source code, but compiler spits out the error "fatal error C1084: Cannot read type library file: 'XXXX.dll': Element not found."
Note that regsvr32 has successfully registered that .dll and .dll's path is correct.
Another spooky observation: OLE View fails to open .dll's IDL file giving me "Could not decompile selected item. Element not found" error message.
If anyone can help, please save me from this miseary.
BIG thanks in advance.
Kirill Sherman
shermank@glstrat.com
|
|
|
|
|
it sounds like you have not compiled your typelibrary into your application. What you need to do is in your .rc file create a custom resource called "TYPELIB" and point it to your .tlb file. This will inclued the tlb in your final compiled DLL so that it can be imported. Your other alternative is to import the actual tlb file instead of the DLL. Hope this helps.
Joseph Dempsey
jdempsey@cox.rr.com
Joseph.Dempsey@thermobio.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
What about your IDL definition?
If you don't mind, show your idl definition.
MIDL compiler don't generate type library without proper keywords.
Regards,
Ryan
|
|
|
|
|
Thanks for your concern, but I asked the author of those VB components to recompile his works.
Don't understand why, but after recompilation, I could view all the IDL's with OLE Viewer and #import them without any problems.
As long as it works - I am happy.
|
|
|
|
|
I have a DLL component with some User Interface sitting on my server machine. My test program is on the client machine. I want my test program to activate the DLL component on the server machine. But I want the UI to be visible on the client machine.
Anyone knows how to do it?
Thanks a lot!
|
|
|
|
|
Hi,
I use a COM object(lot of classes and functions) that does not support the multi thread call.
The program i do is multithread and then i have problem with the COM object.
i would like to serialize all the calls i have to do to this object in a single thread. From the creation of the object to its release.
Can someone help me please?
thanks!
|
|
|
|
|
If you are using ATL, try to use CComCriticalSection object. Create the data member of that type in your class and initialize it in your object's constructor. Use CComCriticalSection::Lock() and Use CComCriticalSection::Unlock() methods in code blocks that require only-one-at-a-time execution (a.k.a. serialized access or thread-safe code). This object is well documented in MSDN library. The alternative to it is Win32 API:
CRITICAL_SECTION hMyCS;
InitializeCriticalSection(&hMyCS);
***
***
EnterCriticalSection(&hMyCS);
// your thread-safe code begings
***
***
***
// your thread-safe code ends
LeaveCriticalSection(&hMyCS);
As opposed to events, semaphores, and mutexes, critcal sections are the easiest and fastest synchronization objects.
Second, events, semaphores and mutexes are mostly used for inter-process syncrhonization and communication, but you still can use them at intra-process level.
When Critical Sections are used, all client threads that access your component will be automatically queued in First-Come-First-Served fashion. Windows and COM runtime will take care of that for you.
Hope you find it helpful.
Kirill Sherman
shermank@glstrat.com
|
|
|
|
|
All right for that,
but even if the threads are queued in critical section, the critical sections are accessed by several threads, not at the same time sure!
I have a class:
Class CObj: public COleDispatchDriver{
public:
LPDISPATCH fct1(COleVariant vrIndex);
short fct2();
};
what i want is that a thread controls the access to fct1 and fct2 as a consequence, only this thread will use these functions!
even if other threads call them, i want to execute these functions always in the same thread!
In fact, it's a problem that i have with an ActiveX i use, its threading model is appartment, but sometime, when i access classes of the activeX with different threads, i have an error (the error is done by the activeX i use, not a window exception). Then, i thought that the best way was to create a wrapper class to the ActiveX, and this wrapper class will always work in one thread. So, all calls to the activeX are serialized.
Thanks!
|
|
|
|
|
That's where COM apartment may help. Your ActiveX control is apartment threaded, which means that all calls to that object always must be executed on the same thread. Looks like your client also apartment threaded, but probably when you use your ActiveX object on other thread you didn't marhsall you interface pointer (CoMarshalInterface or CoMarshalInterThread..).
One possible fix, that won't require much changes, is to put all client threads in free threaded apartment (each thread should calls CoInitialiseEx(NULL, COINIT_MULTITHREADED)). There will be slight perfomance hit, since all the calls to your object will be marshalled. If it's not acceptable ( or the client must be apartment threaded), than you'll need to use CoMarshal../Unmarshall or Global interface table (see IGlobalInterfaceTable, CLSID_StdGlobalInterfaceTable) to marshal interface pointer between apartments. In this case the calls from apartment that created object won't be marshalled.
Hope this helps.
Edward.
|
|
|
|
|
How do you position a chart that was add from excel to the second page. I used the AddOleObject method and i did not specify an anchor. Does anyone know how to set up an anchor?? Any help will be appreciated.
DrunkerII
|
|
|
|
|
I define this struct in my IDL:
typedef struct PATIENT_INFO
{
[string] wchar_t wszLastName[ 50 ];
[string] wchar_t wszPatientID[ 30 ];
} PATIENT_INFO;
When I compile I get this error:
midl\oleaut32.dll : error MIDL2020 : error generating type library : LayOut failed on struct : __MIDL___MIDL_itf_PatientTestSvr_0000_0001
When I take out the [string] attribute it compiles fine.
It is my understanding that the [string] attribute means only the NULL terminated string itself will get marshalled and not the whole buffer (which is the behavior I want).
Is my understanding correct and how can I get this to compile?
Glenn Wardius
GE Medical Systems
|
|
|
|
|
first rid yourself of the [50]'s cause you don't need them. the string attribute tells MIDL to look for the null terminator and it does size calculations on its own. Next get rid of the typedef. MIDL doesn't need it. just use
<br />
struct PATIENT_INFO<br />
{<br />
[string] wchar_t wszPatientID;<br />
[string] wchar_t wszLastName;<br />
};<br />
Hope this helps ya out.
Joseph Dempsey
jdempsey@cox.rr.com
Joseph.Dempsey@thermobio.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
I am using automation to open an Access 97 database, and run a report. It works fine as long as I'm not trying to use a WHERE clause.
For example, this code works fine:
void CAccessReports::RunReport(CString strReportName)
{
if (m_pAccess && m_pDoCmd)
{
m_pDoCmd->OpenReport(
COleVariant(strReportName),
2, // acViewPreview
COleVariant(),
COleVariant());
m_pAccess->SetVisible(TRUE);
}
}
but this code:
void CAccessReports::RunReport2(CString strReportName,CString dfilter)
{
if (m_pAccess && m_pDoCmd)
{
m_pDoCmd->OpenReport(
COleVariant(strReportName),
2, // acViewPreview
COleVariant(),
COleVariant(dfilter);
m_pAccess->SetVisible(TRUE);
}
}
blows up with an Access error:
"Data type mismatch in criteria expression.@@@2@5003464@2"
(My WHERE clause is: [StartDate]>='04/02/2001' and [EndDate]<='04/18/2001')
What am I doing wrong here?
Thanks in advance for any help!
|
|
|
|
|
Hi all,
I am trying to pass BSTR arguments to a component's function from a client !I am using L prefix for the arguments !The problem is I am not getting any argument value in the function at the component !What may be the problem !
How can i successfully pass the BSTR arguments to the Interface function !
Thanx in advance for the help !
Y.Yamini Devi
|
|
|
|
|
Using L before a string makes it Unicode, not a BSTR. Read up on SysAllocString() and related APIs, and the _bstr_t CComBSTR wrapper classes.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Hi Yamini
The component u r using in VC++, i suppose have u tried L"xyz" in this fashion.if not then try it,possibly u will get the answer.Or try in this way:-
CString str;
str="ABC";
str.SysAllocString();
This may solve the problem.
Bye
|
|
|
|
|
Hi Yamini
The component u r using in VC++, i suppose have u tried L"xyz" in this fashion.if not then try it,possibly u will get the answer.Or try in this way:-
CString str;
str="ABC";
str.SysAllocString();
Then pass this instead of BSTR argument.
This may solve the problem.
Bye
|
|
|
|
|
How do I return an array of strings in IDL and COM? E.g. I would like a function that does something like this:
struct StringListType
{
long m_lNumStrings;
[string, size_is(lNumStrings)] wchar_t ** pStrings; // Is this correct???
};
void GetStrings( [out] struct StringListType * pStringList )
{
wchar_t Str1[] = "A silly string!";
wchar_t Str2[] = "You're da bomb ";
// What goes here to put Str1 and Str2 into pStringList???
}
I know I have to do some TaskMemAlloc() but am not sure of the correct way to do it. Also, I'm not sure of the proper way to specify an array of strings in the IDL above.
Thanxs for any help!
|
|
|
|
|
Hi everyone,
I don't know how to use two filtergraphs simultaneously in my application. When I
build two identical filtergraphs to capture two video sources simultaneously, it
works fine when the two filtergraphs run at the same time. But at the time when I
stop them, the application cracks. Each of the filtergraphs can run and stop
properly if the other is stopped.
Does anyone have the same experience as mine? Please help me solve this puzzle
thanks.
|
|
|
|
|
I'm used to using #import on a type library or the DLL itself and using that to set up my smart pointer to the interface(s) I need.
I'm now writing a COM object that wrappers a COM object written in JAVA. I've never even looked at Java before so what I was given is a series of *.class files which are apparently the equivalent of Java "exectuables" of a sort.
At any rate, I know the ProgID and CLSID of the COM object and can look at it under the OLE viewer. What's the correct way to load an interface to this COM object without having a DLL or TLB to import?
Thanks,
Matt Philmon
|
|
|
|
|
I'm used to using #import on a type library or the DLL itself and using that to set up my smart pointer to the interface(s) I need.
I'm now writing a COM object that wrappers a COM object written in JAVA. I've never even looked at Java before so what I was given is a series of *.class files which are apparently the equivalent of Java "exectuables" of a sort.
At any rate, I know the ProgID and CLSID of the COM object and can look at it under the OLE viewer. What's the correct way to load an interface to this COM object without having a DLL or TLB to import?
Thanks,
Matt Philmon
|
|
|
|