|
Here's what I've got:
CDatabase DataBase;
TRY
{
DataBase.OpenEx(_T("DSN=test;UID=;PWD="),CDatabase::noOdbcDialog);
}
CATCH(CDBException,e)
{
#ifdef _DEBUG
MessageBox("ERROR Connecting");
#endif
}
END_CATCH
TRY
{
DataBase.ExecuteSQL("INSERT INTO Annotation (AnnotationID,ImageID,Text) VALUES ('1','2','Capsule')");
}
CATCH(CDBException,e)
{
#ifdef _DEBUG
MessageBox("ERROR Inserting");
#endif
}
END_CATCH
It appears to be connecting fine, but I always get "ERROR Inserting". 'Annotation' is the table I'm trying modify fields in. When I set up my DSN, I put the default database to the one that the table 'Annotation' is in (instead of master or model, etc). What am I doing wrong or failing to do?
halblonious
|
|
|
|
|
Taking a look at e->m_strError to see what the error is seems like a logical first step
|
|
|
|
|
I never even knew to check that. Sadly, though, it doesn't really tell me much. Do you know of a good place to find prototype syntax for this stuff? What I had works for modifying an Access database, but doesn't seem to work on SQL.
halblonious
|
|
|
|
|
could you post the error message?
|
|
|
|
|
At a guess, AnnotationID and ImageID are numeric (integer?) types. Try removing the quoting around them so it's just
VALUES(1,2,'Capsule')
Of course, there may also be uniqueness constraints which stop you inserting the same values more than once...
Steve S
|
|
|
|
|
Has anybody ever noticed that when you compile C++ programs/files that you can use the browse info to locate any and all references of structure elements (in addition to classes, of course), but for C programs/files, the only browse info available for structure elements is the declaration of the struct element?
This is something that has plagued me for several years (over several versions of MSVC), as my work involves a mix of C and C++ programming. I have spent a fair amount of time searching the web for any clues on why this might be or what settings I can change to get the struct element references in my browse info for C programs. I can't seem to find anything or even anybody else even asking the question.
I have found one work-around to be to compile with /TP, which forces C++ compilation. However, this is not a good work-around, because the files are really C files and compiling as C++ produces many errors (many are legacy files which I cannot modify at my whim).
Am I the only person in the world who has missed this capability for C programs? Has anybody ever figured out how to get this capability for C programs? Are there better tools out there for this?
Thanks,
Bob Farrell
|
|
|
|
|
Can someone please tell me how to obtain the Windows handle when you know the windows resource. Its a MFC application.
I need to pass the handle for a push button to another routine. The resource is IDC_TEST1.
I have been trying code snips like:
CWnd *pWnd = FindWindow( "IDC_TEST", NULL );
HWND hWnd = pWnd->GetSafeHwnd();
Note it is the hWnd that I require. The button class names is CHoverButton, but they are several on the dialog. How do I determine the handle for each HoverButton?
The window (Button1 for CHoverButton) is part of my application. I just need the handle to arrange for the resize action of Button1's window.
grahamfff
|
|
|
|
|
HWND hCtrl = GetDlgItem(IDC_TEST1);
INTP
|
|
|
|
|
You want to use: ::GetDlgItem( hDlg, IDC_TEST1); or GetDlgItem( IDC_TEST1); and test the returned handle of course.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Use the methods described in the previous replies. Or, if you are not calling this from the owning window, you can always use EnumChildWindows...
onwards and upwards...
|
|
|
|
|
hello,
So I have written a little application in VC++, and I access a dBase files via ODBC. My development machine has a Win2k OS. I copy all .dbf and all .dbt files from my machine to another one with a WinXP OS.
When I start my application on both machines, I have discrepencies in the number of records returned by my SELECT statement even if the files are totally identical :
it seems than I receive deleted records on the XP machine. When I look at table used with FoxPro on my Win2k machine,all extra records have a black square -I assume this means deleted row? - at the beginning of the row) and that these deleted records are not returned on Win2k machine ...
1) does it look like an already known problem ?
2) on Win2k machine, the MSJET40.dll must be issued from a SP5 when i look at its version#: I wanted to upgrade it to the latest version SP8, but when I try to launch the upgrade exe, I receive an error message that tells me that I must at least be with SP3 ... How is this check performed ?
3) Is there a difference between MSJET on Win2k and winXP ?
Any information or solution is welcome ...
DD
|
|
|
|
|
Most likely the difference is due to the ODBC DSN settings. The Advanced options allow for inclusion or exclusion of deleted records. Check your DSN settings and make sure that they are identical on both machines.
onwards and upwards...
|
|
|
|
|
Hello,
yes, how stupid I am !!
you are totally right, I modified this option on my Win2k station and forget to say to do so when configuring the WinXP station.
Thanks
DD
|
|
|
|
|
My application (Windows service) should wait for new XML files arriving in a specified directory (those files are uploaded there by EXTERNAL FTP process) and process them. To do this I use notification mechanism based on "ReadDirectoryChangesW" API with "FILE_NOTIFY_CHANGE_FILE_NAME" flag. After receiving a new notification and filtering out everything except for "FILE_ACTION_ADDED" one, I start file processing (having a name of newly created file from notification) with MSXML parser.
And here's the problematic place:
If arriving XML file is big enough and "IXMLDOMDocument:load()" method gets called (from notification handler) before file is written down to the disk completelly, this call to load() method fails to complete the operation in the following ways:
- If "async" property of XMLDOMDocument was set to "FALSE", it just returns "FALSE" as a result.
- If "async" property was set to be "TRUE" - it returns immediatelly with TRUE, but every subsequent call to XMLDOMDocument (to getelement or whatever) fails with E_PENDING result. I tried to use "onreadychangestate" event notification mechanism to handle this asyncronous loading, but it always receives only "LOADING", "LOADED" and "INTERACTIVE" (1, 2 and 3) state change notifications and never receives "COMPLETED" (4) notification (and as a result it never lets me call any other methods on the document successfully).
Question(s):
1) is there any way to correctly handle this "SUPER_ASYNCRONOUS" load behaviour at the level of MSXML object.
2) if 1-st option is not possible - is there any way to WAIT in notification handler for the file to be completelly written down to the disk (by external process) before calling MSXML Document::load() method. Here I mean some "appropriate" solution with WaitFor..., async I/O notification handler or something like this - NOT JUST "Sleep( 10000 )" and 100 more attempts to try to load() in a loop.
Andrey
|
|
|
|
|
Hi Andrey,
Isn't the problem that the FTP download hasn't necessarilly completed when you get the initial notification? If so is there a way to check when the file is closed and trigger your MSXML action then. Another option would be to check if any processes have the file open and wait untill none do. Finally monitor the file size and when it stops changing trigger the action. This would be the least reliable.
Hope that helps.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Neville,
that's absolutely right - notification about creation of the file arrives earlier than file is uploaded completelly. But I thought, setting "async" property of XMLDocument to be "TRUE" should handle this scenario (from what I read from Documentation). What I could see from "practice" is it handles correctly only parsing "asyncronously", assuming file was completely written on the disk before. So, I agree with your suggestions, actually I thought about something like this, but:
1) I do not think last option is reliable because it depends of flushing of I/O buffers and will take some tricks to implement (which I think might make it very vulnerable)
2) For 1-st and 2-nd options (which for me sound very similar) I was not able to find "details"/"appropriate Win32 API" how to implement it. The uploading process is external, so I do not have an ability to check directly if file handle was closed.
Indirectly -
Neville Franks wrote:
to check if any processes have the file open and wait untill none do
- what functionality should be used to do this - attempt to CreateFile() with SHARE_EXCLUSIVE mode untill success? Is there any way to wait for file to be released by other process in some "Win32 API Wait()-function"?
Now I see only this solution:
for( int i = 0; i < MAX_OPEN_ATTEMPTS; ++i )
{
bool bOpen = OpenFile( EXCLUSIVE_MODE );
if( bOpen )
break;
Sleep( 1000 );
}
which I do not like because of some hardcoded Sleep statements and possible multiple attempts to open a file in an exclusive mode?
Thank you very much for your responce and I would appreciate if you have any other suggestions/comments.
Best regards,
Andrey
|
|
|
|
|
Hi Andrey,
I can't comment on MSXML I'm afraid as I have never used it. I use pugXml here on CP. Bit that won't help with this problem.
Check for exclusive file access is the approach I would take. However for this to work you have to know whether the FTP process uses exclusive access otherwise this may not work.
If it does then I would simply launch a thread which waited untill it could get exclusive access, which hopefully indicates the FTP process has finished. The thread would then trigger the MSXML parse. I can recommend ThreadLibrary which I use in ED, amongst lots of other thread code. See: http://www.codeproject.com/threads/threadlibrary.asp[^]
If none of this works have a look over at: http://www.sysinternals.com[^] Filemon v6.07 and Handle v2.10
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
#include "stdafx.h"
char lpBuffer[256]
{
GetPrivateProfileString()
"FYP.doc", // LPCTSTR lpAppName
"MyKey1", // LPCTSTR lpKeyName
"0", // LPCTSTR lpDefault - in case file does not exist this is default
lpBuffer, // LPCTSTR lpReturnedString
256, // DWORD nSize
"File.ini" // LPCTSTR lpFileName
WritePrivateProfileString()
"FYP.doc", // LPCTSTR lpAppName
"MyKey1", // LPCTSTR lpKeyName
"0", // LPCTSTR lpString - whatever you want to save
"File.ini" // LPCTSTR lpFileName
}
return 0;
I got two error<br />
1)error C2239: unexpected token '{' following declaration of 'lpBuffer'<br />
2)error C2143: syntax error : missing ';' before 'return'<br />
<br />
Can someone help me debug these two error thanks
|
|
|
|
|
This code makes no sense.
lpBuffer[256] needs a semi-colon
What are the braces for?
Where's the function name?
Why are the strings not in the function calls?
The functions calls have no semi-colons.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
man... that's a weird piece of code!
Just 2 errors for this code snippet is amazing... so be happy
sorry... couldn't resist!
Regards, mYkel
|
|
|
|
|
In VC6 (SP5), when I do:
namespace minsk
{
void f();
};
using minsk::f;
using namespace misk;
void bar()
{
f();
}
I get "ambiguous call to overloaded function"
Is this standard compliant, or a VC6 issue?
Flirt harder, I'm a coder.
mlog || Agile Programming | doxygen
|
|
|
|
|
peterchen wrote:
using namespace f;
What is this for? Do you have a namespace f? I believe the proper call should be
using namespace minsk;
John
|
|
|
|
|
sorry - it is a 'using namespace minsk;'
(was a typo in the original post...)
Flirt harder, I'm a coder.
mlog || Agile Programming | doxygen
|
|
|
|
|
In the edited version you should not need this line as it is redundant:
using minsk::f;
Is the function f() defined in any other namespace or the global namespace?
John
|
|
|
|
|
John M. Drescher wrote:
Is the function f() defined in any other namespace or the global namespace?
No
(I made an "empty" Windows console application to test that)
The problem occurs only if both using statements are there - but unfortunately, I almost can't avoid that.
it's amout std::min and std::max
I've got a library that tries to override the #define min / max in windef.h by using #defining NOMINMAX and using std::min; using std::max
This works well - until there's a .cpp (or a function) that a) says using namespace std and b) uses min and/or max
Flirt harder, I'm a coder.
mlog || Agile Programming | doxygen
|
|
|
|