|
Anonymous wrote:
wat is the name of the MS-access driver...
Look at the Drivers tab on the ODBC Data Source Administrator dialog. It shows:
Microsoft Access Driver (*.mdb)
Anonymous wrote:
2. my log size increases very quickly. i want to rotate the log...
Add a date/time field to the table, and index it. Periodically run through the rows, deleting those that have "expired."
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I dont know much but... "Ms Access uses JET DATABASE DRIVER". You use ODBC which acts as an interface between your application and JET
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
I have developed activex control in MFC. It is text control with additional features.
I am testing it in VB.
Design time properties are getting set.
When I try to set the properties at run time and execute the application I am getting the following error.
If I try to access text property
error is as follows
Method text of object '_DoleEdit' failed
|
|
|
|
|
i have a function IsAdministrator() which tells me whether i the administrator or not(i.e, i have administrative rights). Now i want to include this code in my dialog based application so that only the administrator can run the application. I tried to include it in the InitDialog() but it did not work. Should i put it in the constructor?
|
|
|
|
|
|
put it in InitInstance method of your CWinApp derived class
InitInstance()
{
...
if(IsAdministrator())
{
CMyDialog dlg;
dlg.DoModal();
}
else
{
AfxMessageBox("Your not an admin");
}
return FALSE;
}
|
|
|
|
|
Anonymous wrote:
...but it did not work.
Which tells us nothing. Do you get a compiler, linker, or run-time error? Does an assertion fire? Is an exception thrown? Does the function not produce the desired result? Have you single-stepped through the code to see what specific line fails? Be just a tad more specific.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I am converting some of our projects from Visual Studio 6 to Visual Studio 2003
I have found that the following code gives different results from these compilers
In VS6 "Josh" is printed. in VS2003 nothing is printed.
If I trace into c_str() I can see that the correct pointer is returned to s. However between the call to TestFn() and printf the destructor of stl::string is called. This is for the temp object created when returning from TestFn(). In VS2003 a '\0' is inserted at the fist element in the buffer by this destructor. In VS6 this does not happen.
In VS2003 If I use the memory viewer I can see that s points to a \'0' followed by 'o' 's' 'h' '\0';
In VS6 the same things points to 'J' 'o' 's' 'h' '\0'
Can anyone explain why this is happening?
#include "stdafx.h"
#include <string>
using namespace std;
string globalString = "Josh";
string TestFn()
{
return globalString;
}
int main(int argc, char* argv[])
{
const char * s = TestFn().c_str();
printf(s);
return 0;
}
|
|
|
|
|
Your code is buggy.
TestFn is returning a string object. In your main routine you are getting the const char * of the returned string. Then the string is going out of scope and the memory is being deleted. Finally you do a printf on a pointer that now points to trash.
It worked on VC6 out of luck.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I agree the code is not the best.
Tim Smith wrote:
Then the string is going out of scope and the memory is being deleted.
it seems like in VS6 the temp object created when TestFn() returns goes out of scope at the end of main(), and in VS2003 it goes out of scope after the call to TestFn() but before the return statement
|
|
|
|
|
Josh Gray wrote:
I agree the code is not the best.
I don't think that is the point. The code accesses a memory location of a temporary and then, later, it uses that memory in an instruction. That violates the principles of temporary objects. If you have some compiler or circumstance that causes it to not fail that is pure coincidence and does not change the fact that it is just wrong.
Hate is not a family value.
-pete
|
|
|
|
|
Maybe some scope semantics changed between compiler versions? Dunno
What happens if you try this though:
int main(int argc, char* argv[])
{
//const char * s = TestFn().c_str();
string s = TestFn();
printf(s.c_str());
return 0;
}
|
|
|
|
|
that works and so does this
int main(int argc, char* argv[])
{
//const char * s = TestFn().c_str();
CString s = TestFn();
printf(s);
return 0;
}
this is because the constructor of string and CString copyies the data before the destructor of the temp string object deletes its copy
|
|
|
|
|
This is the correct syntax. You must make a copy of any temp object you receive from a function call if you want to use it in this way (after the return value is evaluated). The original code worked on VC6 because VC6 was not following the standard.
John
|
|
|
|
|
Thanks to everyone who replied.
That explanation sounds reasonable. I plan to change all these methods in our code to return a string reference and see what happens. Fortunatly the 100's of methods that return a string are generated at build time so I can just change the template, rebuild and see what happens.
|
|
|
|
|
Just don't return a reference to a local stack variable. That will cause the same type of bugs.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Yeah I know. The actual problem I am attempting to resolve is 'getter' functions that return a member variable. If i change it to a reference I should be able to use the string while the object remains in scope
|
|
|
|
|
Hi i am trying to set up a tab control in an mfc dialog based application however i have been unable to find just any sort of article or anything on how to just set one up and use it can someone either point me to a good article thatll show me how to set up the panels and move through them or at least give me a brief run down of the functions that are needed in setting it up
Thanks
Tyrus
|
|
|
|
|
|
I need to add a string resource manaully to the .rc2 file in an MFC project, so did this (copying from the syntax in .rc file):
STRINGTABLE
BEGIN
IDS_THESTRING "really long string here.."
END
and with a define inside resource.h:
#define IDS_THESTRING 101
This compiles but the strings defined in the normal .rc file (that are edited through the string table editor in VS) are no longer valid, any attempt to reference them fails.
Is this the correct syntax for manually adding a string resource?
|
|
|
|
|
This is the correct syntax. You just have to make sure two strings don't have the same ID.
John
|
|
|
|
|
I think in your resource.h there is a counter of different controls. You have to set it up by one. (This very maybe could be your problem.)
the counters are round about the last lines of the file.
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I'm a newbie and have an OCX written in VB (from vendor) which I'd like to use with a VC++ application. Is it possible to use the OCX w/ out a form/dialog, and if so what needs to be done outside of importing it to the project?
Newbie1
|
|
|
|
|
Usualy when i validate data on the OnOK of a CDialog , i can "return", and the OnOK is simply canceled, the dialog remains open.
I whant to make the same thing with a property page:
Needed result:
- Property sheet with multiple pages.
- Validate data on the OnOK of the pages and prevente property sheet closing if necessary
Problem:
- When i press OK button,and "return" , i can "cancel" the OnOK of that page only
- the OnOK was fired and the property sheet closes.
does any one knows how to do this? (i have searched the forums with no results)
thanks.
|
|
|
|
|
Override OnApply() (called when the Apply or OK buttons are pressed) and return TRUE to continue, or FALSE to abort the operation.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|