|
Interesting... If I make the line
sprintf(pChar, "Provider=Microsoft.Jet.OLEDB.4.0;Jet Engine Type=5;Data Source=%s;", (char*)DatabasePath);
then I get an error:
Could Not Find Installable ISAM.
Do you know what this means ? BTW the Microsoft exmaples in C++ don't use the 'Jet OLEDB:Engine Type= ' parameter and create useless files just like my code does.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
To be honest I just got the code from a friend of mine and thought that maybe you could use it...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Whoops - fixing the syntax gives me a database I can read from but not write to, for some reason...
Thanks for the step forward. Now I just need to figure why I cannot write to it...
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
The specific problem now is when I try to add data:
if (records->RecordCount != 0)
records->MoveFirst();
CComBSTR bstrPath;
(*it)->get_FilePath(&bstrPath);
char * pStr = new char[bstrPath.Length() + 24];
memset(pStr, 0, bstrPath.Length() + 24);
sprintf(pStr, "[FilePath] = \'%s\'", (char*)(_bstr_t)bstrPath);
try
{
records->Filter = (bstr_t)pStr;
}
catch (...)
{
MessageBox(NULL, "Error", pStr, 0);
}
string renderpath = (bstr_t)bstrPath;
for (string::iterator itr = renderpath.begin(); itr != renderpath.end(); ++itr)
if (*itr == '?') *itr = '\'';
CComBSTR callback(renderpath.c_str());
Fire_ScanningFile(callback);
if (records->RecordCount == 0)
{
The above code opens the recordset, moves to the start if it has records, replaces ? with ' in the filename ( having ' in my records killed my query statements ), sends a callback and then checks if the record count is 0 after the filter, which means I should add the record. Now if I create the DB programatically, this code always falls through, and records->RecordCount ALWAYS equals 1 ( tried with zero, one and two records in the DB. The odd thing is that everything is fine in Access, I can add & remove records, and they show OK in my program. The *other* odd thing is if I called Records->MoveFirst() when there were zero recordsin the DB created in Access it would crash, unless it crashes if it finds zero for no REAL reason, and for some reason it's finding one, which is OK.
Argh !!!!!
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I'm not sure if I got this right, but:
1. How are you opening your recordset? Recordcount returns different numbers depending on cursor type you choose.
2. Use EOF instead of recordcount to check the status of your recordset. You always have to check eof before using Move(...) functions.
HTH
Regards,
Wanderley
|
|
|
|
|
Thanks for the reply.
1/
_RecordsetPtr records = NULL;
records.CreateInstance(__uuidof(Recordset));
try
{
records->CursorType = adOpenStatic;
records->CursorLocation = adUseClient;
records->Open("SELECT * FROM FileDatabase",
_variant_t((IDispatch*)m_Connection, true), adOpenKeyset, adLockOptimistic,
adCmdUnknown);
}
catch(...)
{
}
This works with the db created in Access, but the one I am now creating in ADOX opens fine, reads fine, but the Filter always returns that I have one record.
2/ I was using EOF to start with, I changed it to RecordCount when I was trying to fix this problem. Same result both ways.
Thanks for any suggestions you may have...
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hi
Did you fix you problem? One day away from CodeProject and your message almost disappeared
Is there any reason to use Filter instead of opening your recordset using WHERE in your SQL statement? This way you can check for EOF right after you open the recordset.
I have no clue why it works when you create your db in Acess - maybe a bug in ADOX... Anyway, could you send me some files to check if I have the same problem here?
Regards,
Wanderley
|
|
|
|
|
Thanks for the reply.
Two reasons:
1/ I am filtering by each potential new record in order to find out if it exists, so I don't want to open the recordset over and over
2/ When I've tried to impliment filter, it crashes every time.
The thing I don't get is if ADOX is the problem, why is the created DB file exactly the same as the one Access creates and allows me to add data within Access... I'll send you a zip of some files, thank you.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I created ATL and I want to use it in my project (MFC Dialog project)
But I dont success to create Instance of my ATL.
I maked so :
---------------------------------------------------------------------
insert the files: MyAtl.dll /.h/_i.c to my folder
---------------------------------------------------------------------
#include "MyAtl.h"
#include "MyAtl_i.c"
---------------------------------------------------------------------
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr)){ .....}
IAtlObj *pHello=NULL;
hr =CoCreateInstance(CLSID_CIQS, NULL,CLSCTX_ALL,IID_ICIQ, (void**&pHello);
if (FAILED(hr)) {.......} //==>> and in runtime it is failed here
----------------------------------------------------------------------
What is the problem ?
|
|
|
|
|
It's easier to use #import if you can. Have you checked to see what the error is ? Does the above line have a typo so that you're really casting to void ** ( no close brackets ) ? Also should it be CLSID_CIQ*S* but IID_ICIQ ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thank you Christian !
I checked it and is all right (Have not typo):
void** in close brackets and I writed : IID_IMyObject
and although it dont succeess. It passed compilation ok but it dont create the instance in run time.
Are you sure that this is all right in my steps as I tell you that I did ?
if so it seems that the problem is in my ATL
|
|
|
|
|
|
If you expect an answer within four minutes, you'll need to register so I get an email to say you replied to my post.
Have you tried #import ? Did you check the error ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
excuse me on my nervous and on my stupid question :
How can I use at #import ?
Can you write me a line code for example ?
|
|
|
|
|
No worries - questions are what this area is for. If you read the lounge at the moment, I've commented there on my feelings regarding anonymous posts, but I'm still glad to help if I can.
You can access your ATL object in one of two ways. First you can do the #include thing, which gives you named guids and the headers you need, so you can do what you've tried. #import looks like this:
#import "..\ATL\SADatabase\SADatabase.tlb" no_namespace named_guids
This imports the type libray, the options I specified mean there is no namespace ( for example if I import ADO without this option I need to using namespace ADO;, or ADO:: everything. ), and give me those named guids. They also give me smart pointers I can use to easily create things and not worry about releasing them.
Like so:
IEnumSAFileEntryPtr pIEnumDB;
ISAFileDBPtr pIFind(__uuidof(SAFileDB));
HRESULT hr;
try
{
if (pIFind == NULL) return;
if(FAILED(pIFind->Connect(m_DBPath)))
{
AfxMessageBox("Failed To Connect");
return;
}
hr = pIFind->GetDatabase(&pIEnumDB);
pIFind->CloseDB();
}
catch (...)
{
pIFind->CloseDB();
AfxMessageBox("Error reading dabatase");
return;
}
These are blocks of code from my current home project, and they all work nicely. The smart pointers are the interface name with Ptr after them, and IEnumSAFileEntryPtr is an enumeration object, created later. The line ISAFileDBPtr pIFind(__uuidof(SAFileDB)); creates the object in my smart pointer - much nicer, doncha think ?
Try that and let me know how you go. If hr still fails, find out what the value is ( in terms of what error it is reporting )
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thank you !
But I dont find in my computer the path: ...ATL\SADatabase\SADatabase.tlb
So what is your mean in the line :
#import "..\ATL\SADatabase\SADatabase.tlb" no_namespace named_guids
|
|
|
|
|
OK, you're a beginner.
That is the path to *my* type library, you need the path to *your* type library. The same as the path to the files you #included previously.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Just because it compiles doesn't mean it works.
You do need to bracket the void**
hr = CoCreateInstance(CLSID_CIQS, NULL,CLSCTX_ALL,IID_ICIQ, (void**)&pHello);
Also what is the value of hr? I case you don't know you can format HRESULTS in the watch window to help decypher them. i.e. hr,hr shows as S_OK (or E_FAIL, etc).
|
|
|
|
|
I want to define a CString in a DLL file so I can share the data.
I simple use the String Table in DLL project, with the value IDS_STRING1 1.
I use the statement
#define IDS_STRING1 1
in the project to which I want to add the DLL. And I also add the .Lib file and the .dll file to the destination project.
But the method does not work.
How to resolve the trouble?
Thanks.
Maer
|
|
|
|
|
Well there are a lot of methods for sharing data between DLL's..but in your case why don't you export a function from the DLL which will return a pointer to the string..
char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Hard work has a future payoff. Laziness pays off now.
|
|
|
|
|
Thanks pal.
Your method works, I know. I have used your method before, the method I am using now is a new one that I have never used.
I just want to have a try. : )
Best regards.
Maer
|
|
|
|
|
First, I am not really sure, whether You can use value 1 for string. There a table is somewhere in MSDN which shows ranges for data types stored in resources.
If You want to load this string from dll, You've got 2 solutions:
1) dynamically load dll, by using LoadLibrary(), then LoadString with instance argument pointing to that dll.
There is also an option to create resource only dll. Search for "resource only dll" string in MSDN to read about it.
2) Generate lib and dll, link mentioned lib into the exe, and simply call "LoadString". But, the resource numbers must be unique (at least in type and number). And as I wrote before, try using higher number, for instance: 10000.
According to MSDN documentation:
Prefix Resource Type Valid Range
IDR_ multiple 1 -> 0x6FFF
IDD_ dialog templates 1 -> 0x6FFF
IDC_,IDI_,IDB_ cursors, icons, bitmaps 1 -> 0x6FFF
IDS_, IDP_ general strings 1 -> 0x7FFF
ID_ commands 0x8000 -> 0xDFFF
IDC_ controls 8 -> 0xDFFF
Reasons for these range limits:
By convention, the ID value of 0 is not used.
Windows implementation limitations restrict true resource IDs to be less than or equal to 0x7FFF.
MFC's internal framework implementations reserve several ranges: 0xE000->0xEFFF and 0x7000->0x7FFF.
Several Windows system commands use the range of 0xF000 -> 0xFFFF.
Control IDs of 1->7 are reserved by IDOK, IDCANCEL, and so on.
The range of 0x8000->0xFFFF for strings is reserved for menu prompts for commands
mukkie
|
|
|
|
|
Hi, mukkie!
Thanks for your reply.
I have checked my two projects, the identifier 1 for string is unique.
My question is how can I define a string with the String Table in a DLL so other program can use. I do not want to simply use a function to return a string.
Can you help?
Best regards,
Maer
|
|
|
|
|
If you go to ms word and insert a symbol, there exists the character of a dot. It's not a period, it's a vertically centered dot that's kinda bigger than a period.
How can I get this as a CString? Something like:
CString symbol = char(?????);
How do you find this value? I looked all over MSDN and I can't find it.
Please, any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
The ANSI character 183 (decimal) is a vertically centered dot.
If you are using any peculiar fonts or what not, you may have problems.
|
|
|
|
|