|
Christian, is easy, convert the FILETIME to COleDateTime then convert the COleDateTime to variant for send to Ado.
Please Christian see in the classes that I sent you, you can see that conversion in the method SetFieldValue....
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
I have got filtering working in my recordset but I have some real problems.
1/ I'm not sure how all the string types/functions fit together. I've read the chapter in ATL Internals, but it does not appear to have gelled. I'm trying this:
CComBSTR bstrPath;
(*it)->get_FilePath(&bstrPath);
char * pStr = new char[bstrPath.Length() + 20];
memset(pStr, 0, bstrPath.Length() + 20);
sprintf(pStr, "FilePath = '%s'", (_bstr_t)bstrPath);
MessageBox(NULL, pStr, "", 0);
If I
ATLTRACE(bstrPath) the value coming in is OK, but the value in the message box is garbage. What am I missing ?
Also, I get my string together like this:
CComBSTR query = "FilePath = '";
query.Append(bstrPath.Copy());
query.Append("'");
records->Filter = (_bstr_t)query;
Now my string is as I want it to be, but the program crashes on the Filter call. I know I'll get a crash if I pass in bad SQL, but if I pass in the same string verbatim, it works fine. What's wrong with passing in the string as a variable, with the same value ? If I do this:
_bstr_t bquery = "FilePath = 'f:\\biblio1.mdb'";
records->Filter = bquery;
then it appears to work fine, so I presume it's back to me not getting the string thing...
Please help - I'm going mad here.....
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 Chris!!!
I Know you.....
What happens with
"FilePath = \"f:\\biblio1.mdb\"";
You can see that I change the ' with ". Some databases are a little ..(I don't know the word) but for example when you use a string that is greatter than 30 characteres is better to use "" and not ''. The SQL Server cut the words in that case.
Carlos Antollini.
|
|
|
|
|
Thanks for trying to help, but it makes no difference if I use single or double quotes - if I use the code that builds a search string, the string is exactly what I would pass in, but if I pass it in manually or through a _bstr_t object I create in one line (_bstr_t t = blah blah ) then it works, but if I build the string using my variable the string is the same and the program crashes.
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.
|
|
|
|
|
When I make a cast to _bstr_t I always use
_bstr_t(str); //when str is for example a CString.
I suspect that you have a problem in the sprintf.
I saw that you pass a parameter making a cast to _bstr_t. I think that is better to make a cast to (LPCTSTR) in the sprinf....
I hope to help you Christian...
Carlos Antollini.
|
|
|
|
|
Thanks - now the sprintf is returning the right result and I pass it in like this:
records->Filter = (_bstr_t)pStr;
This still crashes in the Filter() command, although the string going in is still exactly the same string I have previously created in a single line and passed in. I've tried \n and \0 on the end of the string to no avail.
Thanks for helping
Christian
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.
|
|
|
|
|
It would appear the ADO error only occurs if there are spaces in the field. How do I get around that ? I've put them in quotes (tried single AND double)...
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 know that problem.
In DAO the engine supports the names with space but using this notacion [Field Name] but in ADO I saw that this don't work. Is for this that Always I use the name of the Fields without spaces. If is necesary I prefer to use Under score => _
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
>>>
CComBSTR bstrPath;
(*it)->get_FilePath(&bstrPath);
char * pStr = new char[bstrPath.Length() + 20];
memset(pStr, 0, bstrPath.Length() + 20);
sprintf(pStr, "FilePath = '%s'", (_bstr_t)bstrPath);
MessageBox(NULL, pStr, "", 0);
<<<
try this;
sprintf(pStr, "FilePath = '%s'", (char*)(_bstr_t)bstrPath);
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Thanks - that works, but this line:
records->Filter = (_bstr_t)pStr;
still crashes. The string works if I pass it in manually or through a seperate _bstr_t. Creating a _bstr_t from pStr does not help.
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.
|
|
|
|
|
What is 'records', or actually beter yet, what does type is 'Filter'.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Records is a _RecordsetPtr. I am in ATL, no MFC support. The filter method of the Recordset works perfectly if I pass in the same string, but hard coded or created as a _bstr_t from a hardcoded value. The program crashes if I try it with the variable, if I use try/catch I get a meaningless 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.
|
|
|
|
|
That line crashes because (_bstr_t)pStr creates a temporary _bstr_t object which then gets deleted right away. That leaves records->Filter pointing at invalid memory. (This assumes records->Filter is a BSTR or other pointer type.)
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
It's a _variant_t, but even if I create the _bstr_t seperately, it still crashes. I am certain it crashes because ADO does not recognise the command as valid, even though the syntax is the same when I pass in a hard coded value and it works.
_bstr_t s = pStr;
records->Filter = s;
Crashes
_bstr_t s = "FilePath = 'f:\\bibloi1.mdb'";
records->Filter = s;
works, even though the string I bring up in a MessageBox ( pStr) is exactly the same.
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 guessing you've already tried this, but maybe a little sanity check is in order;
_bstr_t s = pStr;
_bstr_t s2 = "FilePath = 'f:\\bibloi1.mdb'";
if ( s == s2 ) {
MessageBox ( "They are the same!!!");
}
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
It would appear the ADO error only occurs if there are spaces in the field. How do I get around that ? I've put them in quotes (tried single AND double)...
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.
|
|
|
|
|
You have probably already figured this out, but if your DB allows spaces in field names (e.g. Access) most impls I've seen (i.e. Access) want you to surround them with [] brackets.
Careful though - SQL Server (which doesn't allow spaces, AFIK) will err out on you if you try to add the [].
It may be almost a rule of thumb that if you retrieve a field or table name that has an 0x20 in it you should slap the []s on 'em, and let 'em go otherwise.
|
|
|
|
|
Hi,
the explanation why
sprintf(pStr, "FilePath = '%s'", (_bstr_t)bstrPath);
doesnt show the expected result is that reference types doesnt work with va_args (functions with variable number of args - ellipsis). You have to explicitly cast via (LPCSTR) or better use _stprintf( buf, _T("<format string="" here="">"), (LPCTSTR) reference_type, ...); for supporting both unicode and ansi versions.
KB id: Q119394 convers this problem and another possible (nonportable) solution.
Cheers,
A. Focht.
|
|
|
|
|
I can't seem to get the GetMenuItemInfo function to work.
Here's my code, please tell me what I'm doing wrong.
HMENU hMenu = CreateMenu();
HMENU hPopupMenu = CreatePopupMenu();
::InsertMenu(hPopupMenu, 0, MF_STRING | MF_BYPOSITION, 0, "My PopupMenu");
::InsertMenu(hMenu, 0, MF_POPUP | MF_BYPOSITION, (UINT)hPopupMenu, "My Menu");
::SetMenu(GetSafeHwnd(), hMenu);
MENUITEMINFO mii;
memset(&mii, 0, sizeof(MENUITEMINFO));
mii.fMask = MIIM_STATE;
if(::GetMenuItemInfo(hMenu, 0, FALSE, &mii))
{
mii.fMask = mii.fMask | MIIM_STATE;
mii.fState = MFS_CHECKED;
::SetMenuItemInfo(hMenu, 0, TRUE, &mii);
}
else
AfxMessageBox("Err!");
|
|
|
|
|
You didn't set the cbSize member of MENUITEMINFO.
mii.cbSize = sizeof(MENUITEMINFO);
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
There is an article listed here:
http://www.codeproject.com/listctrl/emptylv.asp
and an identical article with more comments listed here:
http://codeguru.earthweb.com/listview/EmptyLV.shtml
I have a CFormView with 2 CtrlList in there. I can't implement either article. I just want it an empty CtrlList to print somethign that tells the user it's empty right now.
By chance, can someone, anyone make this work? Please, any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
What I do is write a custom draw handler, and in the CDDS_PREPAINT stage, if the list is empty, call TextOut() to display "There are no items to show" or whatever message you want.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
Hello,
How can I resize my dialog height to fit the screen - the taskbar when someone drags it to the edge of the screen? I don't want all the specifics just some explanation. Currently I have a dialog that snaps to the screen border and when it snaps to the screen edge I use SetWindowPos(NULL, 0, 0, rc.Width(), rcDesktop.Height() - bottomTaskbar, SWP_NOMOVE|SWP_NOSENDCHANGING); but it keeps resetting it back to its normal size after I call that... any ideas? Thanks in advance.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Type A:
// the following code is OK
CFileFind l_Blah;
l_Blah.FindSomthing("c:\\dir123\\*.abc");
while (l_Blah.FindNextFile())
{
l_Blah.GetFilePath();
}
Type B:
// and the following code is NOT OK
CFileFind l_Blah;
CFileFind l_Blah;
l_Blah.FindSomthing("c:\\dir123\\*.abc");
l_Blah.GetFilePath(); // <--- this line makes an error
while (l_Blah.FindNextFile())
{
l_Blah.GetFilePath();
}
if I use Type A, I always lose the first file that found.
What can I do????????????
Name: STR
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject"
|
|
|
|
|
You need to do it something like this
CFileFind finder;
BOOL bContinue = finder.FindFile("bla.bla.bla");
while (bContinue)
{
...
finder.GetFilePath();
...
bContinue = finder.FindNextFile();
}
|
|
|
|