|
Hi
My application is in C++/ATL/COM and uses the Access database for storing configurations. Various DLLs and EXEs (and threads) that are part of my application query the database when needed.
When doing so, I am getting the database locked message ('[Microsoft][ODBC Microsoft Access Driver] The database has been placed in a state by an unknown user that prevents it from being opened or locked' in the log) randomly and the application fails to continue.
I am assuming that this problem happens due to the shared access of the database.
My question is:
Can i get the complete database in memory (in form of recordsets for every table) during the launch and query the recordsets directly instead of querying the database? I believe this might solve the database locking problem.
Any help is appreciated.
Thanks
Selva
Selva
|
|
|
|
|
A better solution would be to locate and fix the problems.
Some hints:
- Open database read only when no data should be written
- When opening/accessing and the database is locked, retry operation after some time
- When writing to the database, lock the thread so that other threads are blocked
- When writing, close the database aftwerwards to avoid locking states
|
|
|
|
|
Hi Jochen
Thanks for your response.
I am already reviewing the code and doing that. But still it fails at times. So I was thinking whether i could keep them all in memory so that the DB hits can be avoided.
Please share your thoughts.
Thanks
Selva
Selva
|
|
|
|
|
If you have it in memory, you won't get changings. And if you add code to support changings during runtime, you may not need a database.
Assuming that all modules must then use only one function to access the memory db, why not implement the only function using direct db access?
In both cases, that function must be thread safe using locking. I think that's your problem: You access the db from different threads which may fail when the db is locked by another thread. You will have similar problems when using a memory image that is modified when not using locking (but without getting an error message).
|
|
|
|
|
i need an urgent help on this plz explain it cleraly how we can add a picture control or any other control inside list control mfc ,,,reply me as soon as possible
|
|
|
|
|
|
|
If you want to put a background picture on a listcontrol, look here[^] and if you want to insert any kinf of control (COleDateTime, CComboBox, CEdit, and so on) to a listcontrol look here[^].
|
|
|
|
|
hi, i'm developing an application for a school project in wich i need to read the data that an open port is about to send to another.
is there any way that i can do that?
i have search in everywhere and it seems to be no answer for that.
can anyone help me?
thanks
|
|
|
|
|
A serial port can be opened only by one application/thread at time. So there is no chance to do this in a simple way.
You may use some hardware that splits the serial lines and mirrors it to another port where you get a copy of the data that has been send.
You may create a special send thread that copies the data to a buffer before sending and flushes the buffer after they has been sent. You can then query the unsend data from this thread.
|
|
|
|
|
I suppose you should hook the WriteFile function. Not an easy task, anyway.
Veni, vidi, vici.
|
|
|
|
|
Or you can create an upperfilter driver for serial.sys and pump the data back up to your app.
Of course this is extremely difficult for most people to do but should you feel up to a mammoth challenge, it is an interesting way to do it.
The other way you can do it is to create a dll that manages serial.sys, ie, implements all the Win32 serial functionality and get the other app to talk to your dll instead of the stock system one. But this has its own problems in terms of replacing the system dll with yours.
|
|
|
|
|
|
The latest version can be found here
|
|
|
|
|
Hello,
My C/C++ skills are minimal but I would like to see if I can somehow compile a working sample to write a multi-level Window shell extension à la 7zip.
I read the article "The Complete Idiot's Guide to Writing Namespace Extensions" from 2001. I was wondering if someone could tell me...
1. If that sample can be compiled as-is or requires some extra work
2. If yes, can it be compiled with a free C/C++ compiler for Windows?
Hopefuly, once I get everything installed and the sample compiled, I can start peeking and poking to see if I can customize it to build my own shell extension.
Thank you.
|
|
|
|
|
fredtheman wrote: My C/C++ skills are minimal There a re lots of articles here[^] and elsewhere on the internet that will help you learn.
fredtheman wrote: but I would like to see if I can somehow compile a working sample to write a multi-level Window shell extension à la 7zip. Given your previous statement I would think that somewhat over ambitious.
What you can do, is get hold of the free Visual C++ Express system[^] and start building your skills and experience.
|
|
|
|
|
Thanks for the links. I'll give it a try and see if I can figure it out.
|
|
|
|
|
Hi,
if I call CWinApp::GetProfileString() for a key that does not exist, it creates one for me.
This is not what I want.
Is there any way to stop this key from being created?
BTW, I read Stuart Konens CRegistry class article, but cannot use that as third party code is not allowed in my current project.
Thanks,
Bryan.
|
|
|
|
|
The best way would be not to use GetProfileString() but instead use the Registry Functions[^] directly. That way you can check first if the key exists and only create it when necessary.
|
|
|
|
|
Thanks, but...I decided to keep the CWinapp functions as-is.
I just check after the GetProfileString() and if the key has a dummy value, I just delete it.
Works for me.
|
|
|
|
|
We have migrated our application which was written in VC 6.0 to VS2010.
The application crashes on launching it.
The crash occurs at ProcessShellCommand( ). On debugging got this error
"Unhandled exception at 0x7575d36f in MyApp.exe: Microsoft c++ exception CInvalidArgException at memory location 0x0012fb98"
What could be the problem and possible fix for this.
Thanks in Advance.
|
|
|
|
|
V K 2 wrote: What could be the problem
The problem is that you are trying to use an arguement that the function will not accept.
V K 2 wrote: possible fix for this
One possible fix is to use an argement that the function will accept.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
modified 11-Jul-12 9:36am.
|
|
|
|
|
Sheer poetry.
|
|
|
|
|
We can but try....
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
V K 2 wrote: The crash occurs at ProcessShellCommand( ).
Which is called how?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|