|
Hello,
I use the ODBC driver "dBase Files" (installed on my station by microsoft application, I guess).
hereunder is the code I wrote to access the C:\Documents and Settings\dd\Mes documents\GSTAT.DBF file :
#define DBName "DSN=dBASE Files;UID=WD:"
...
CDatabase gDB;
CRecordset rs(&gDB);
CString res;
CString ErrMsg;
CString CASHT;
CString NETROOM;
CString DATUM;
int NbRecord;
CString Path = "C:\\Documents and Settings\\dd\\Mes documents\\" ;
CString File = "GSTAT.DBF" ;
ErrMsg = "";
res = "SELECT DATUM,CASHT,NETROOM from ["+File+"]";
// res = "SELECT DATUM,CASHT,NETROOM from ["+File+"] WHERE (DATUM = 20010208)";
// res = "SELECT DATUM,CASHT,NETROOM from ["+File+"] WHERE (DATUM = '20010208')";
// gDB.OpenEx(DBName,CDatabase::noOdbcDialog);
gDB.OpenEx(DBName,CDatabase::forceOdbcDialog );
TRY
{
rs.Open( CRecordset::forwardOnly, res );
NbRecord = rs.GetRecordCount();
}
CATCH(CDBException, e)
{
ErrMsg ="**ERR: "+e->m_strError.Left(70);
}
END_CATCH
if (ErrMsg == "") {
while(!rs.IsEOF()) {
rs.GetFieldValue( "DATUM", DATUM);
rs.GetFieldValue( "CASHT", CASHT);
rs.GetFieldValue( "NETROOM", NETROOM);
rs.MoveNext();
}
}
rs.Close();
gDB.Close();
Used like this, it works but I have some problems :
1) I am obliged go thru the ODBC display to give again the name of the file, I can't set it by program ... why ? How can I do this and use the noOdbcDialog option (When I try to use it, ODBC tells me that it can't find GSTAT.DBF)?
Furthermore, ODBC dialog is based on program directory, not on the path. If I add the Path to the name in File variable, ODBC tells me that it can't find C:\Documents and Settings\dd\Mes documents\GSTAT.DBF ...
2) If I add the clause "WHERE" to my request, no record is returned ... why ? Can't I use it ? Am I obliged to read all records and test the DATUM field by program ?
3) what is the format of the date in the file ? Excel says 08/02/2001, Word says 20010208 and DATUM = 2001-02-06 when debugging my code ... When I use a date in format yyyy-mm-dd or dd/mm/yyyy ODBC tells me that my format is not compatible with data type
Thanks in advance
DD
|
|
|
|
|
Qadddd wrote:
1) I am obliged go thru the ODBC display to give again the name of the file, I can't set it by program ... why ?
It sounds like the "dBASE Files" DSN is not configured correctly. If it was, there would be no reason to specifiy filenames, database names, paths, etc in your code.
Assuming the database exists, you can create the DSN programatically by using SQLConfigDataSource(NULL, ODBC_ADD_DSN, ...) .
Qadddd wrote:
res = "SELECT DATUM,CASHT,NETROOM from ["+File+"]";
I don't use .dbf files, but I think that File should be the name of a table within the database.
Qadddd wrote:
If I add the clause "WHERE" to my request, no record is returned ... why ?
What type of column is DATUM? It looks sort of like a date column, which means you use #02/08/2001# to compare against.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
DavidCrow wrote:
It sounds like the "dBASE Files" DSN is not configured correctly. If it was, there would be no reason to specifiy filenames, database names, paths, etc in your code.
yes, as I said myself before, I just discover on ODBC pannel the check saying that the current directory is the home directory for my file, I will go deeper in investigations tonight
DavidCrow wrote:
Assuming the database exists, you can create the DSN programatically by using SQLConfigDataSource(NULL, ODBC_ADD_DSN, ...).
that's a good point ! because when I put my little applications on several stations, I always have to configure manually ODBC, I could do it in a little installation executable. The same, if you have a piece of advice to automate the installation of a new ODBC driver ... I take it .
DavidCrow wrote:
I don't use .dbf files, but I think that File should be the name of a table within the database.
That's what my MySQL statement looks like, but for .dbf files ?? I looked at 2 or 3 examples using this syntax and it seems that I can access the file like this without too many problems ... 2 good reasons to keep it like that until someone tells me that my manner is totally wrong )
DavidCrow wrote:
It looks sort of like a date column, which means you use #02/08/2001# to compare against.
It's probably the reason, I will test it ASAP
Thanks
DD
|
|
|
|
|
I am having great difficulty getting pointers to GDI+ objects working in Doc/View under VC6.
The section of code from a Doc/View implementation (Wizard generated, no changes made):
#define TEST_POINTER
void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
#ifdef TEST_POINTER
Graphics* graphics = new Graphics(pDC->m_hDC);
Pen* pen = new Pen(Color(255, 0, 0, 0));
graphics->DrawLine(pen, 50, 50, 350, 550);
graphics->DrawRectangle(pen, 50, 50, 300, 500);
graphics->DrawEllipse(pen, 50, 50, 300, 500);
delete pen;
delete graphics;
#else
Graphics graphics(pDC->m_hDC);
Pen pen(Color(255, 0, 0, 0));
graphics.DrawLine(&pen, 50, 50, 350, 550);
graphics.DrawRectangle(&pen, 50, 50, 300, 500);
graphics.DrawEllipse(&pen, 50, 50, 300, 500);
#endif
}
compiles when TEST_POINTER is UNDEF'd but not when it is defined. I get the error message "error C2660: 'new' : function does not take 3 parameters" for the two 'new' functions.
As far as I can see the global new function is being called instead of the operator::new that the classes implement.
Can somebody tell me how to use GDI+ class pointers ? I need to use pointers as I am implementing pen/brush caches in a CAD.
Any advice would be greatly appreciated.
|
|
|
|
|
Sorry, found the answer.
The solution is to get rid of '#define new DEBUG_NEW' in the source file(s) where the pointers are used.
Apologies for any time wasted.
|
|
|
|
|
Can I retrieve a pointer to the listbox of a combobox in CBS_DROPDOWNLIST style?
I'd like to change the dropped rect, but unfortunately there is no SetDroppedRect().
The thing is that the strings in the list are to long to display fully onto the screen. Therefore I am obliged to use the horizontal scrollbar. The problem is that the vertical height of the dropped list is adjusted to the count of items, when the total item-height is smaller than the created combobox height.
In case of 1 item (very large string) the horizontal scroll bar is invisible.
In case of 2 items the second item is covered by the scroll bar. This does not look nice!! It seems that the height of the horizontal scroll bar is not taken into account during the making of the Dropped list box.
Does anyone have a solution like retrieving a pointer to the listbox to adjust height. All help is welcome.
Toon Schellinck
|
|
|
|
|
Hi !
I'm wondering how a bool type is supposed to work regarding boolean operations :
If I do this :
bool a=true;
bool b=false;
b&=a;
It is working, but is it a coincidence (because & is a bitwise operation) ? Or am I supposed to do :
b&&=a;
or
b=b && a;
????
What do you think ?
Jerome
|
|
|
|
|
Jerome Conus wrote:
...because & is a bitwise operation) ?
And a bool type has 8 bits!
What exactly are you trying to accomplish?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hi guys,
I would like to know how to extract the differents formats provided in an icon?
ExtractIconEx just extract the icon but you have no control on its formats. I want for example to extract the 16x16 256Colors format of a given icon (if such format is defined in the icon). How to do that? Can any body show me the sample code for doing this? Icon editors can do this, so I guess there is a trick for that!
Thanks.
Bouli.
|
|
|
|
|
|
Thanks, it's helpfull...
I thought it was easier for doing this, but the code is awfull... I'm going to study this sample.
thanks again
bouli.
|
|
|
|
|
My pleasure
And all the girlies say I'm pretty fly for a white guy
|
|
|
|
|
hello,
i have prepared a software.i m in windows 2000 professional ...the executable file is here. how do i install in another machine remotely .the remote m/c is either windows2000 or win 98/95 ???
if anybody have code (in C++,VC++,MFC,win32) or links please inform.
please suggest some function (win32) to do that.
skpanda
|
|
|
|
|
If the file is a single executable, one option is just to copy it over. If you need to make registry settings (like add your program to start-up or save it's settings during the installation), then perhaps you could utilize a Remote Desktop connection ?
Otherwise I think the best solution would be to just walk over and install the program manually. Network installations are always tricky, mostly due to firewalls and other protection schemes. No matter the mechanism, the target computer's owner should be allowed to decide whether to install the program or not.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I am trying to get handle of Edit box of Login Window of Yahoo. FindWindowEx is failing.
if(strcmpi(ClassName,"YahooBuddyMain")==0)
{ HWND hwndChildAfter,hChild;
HWND hYahooLogin = FindWindow("#32770","Login");
hChild = FindWindowEx(
hWndYahoo, // handle to parent window
hYahooLogin, // handle to a child window
"EDIT", // pointer to class name
NULL // pointer to window name
);
}
Cheers!!!!!!!!
Siddharth
|
|
|
|
|
Where are you writing this code ?
in the HOOK Handler ?
Then it is possible that the login dialog is not created Yet .
Instead Wait for the creation of
#32770 (Dialog)
if you find one then check whether its parent is YahooBuddyMain
Hope it Helps
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Perfect. Mission accompalished. Thanx a lot frm bottom of my heart.
Cheers!!!
Siddharth
|
|
|
|
|
My pal had created a property sheet and added few pages to it. Well every thing works fine and so on.
There are three buttons Ok, Cancel & Apply. my problem is that these buttons dont have short cut keys,
so my question is how do i set a shortcut keys to those buttons.
I Touched Osama Bin Ladens Bushy Beard
|
|
|
|
|
I've been considering purchasing the VS NET but i have a couple of questions before i commit.
1. Am I missing out if I don't purchase VS NET particularily if I program in C++ (MFC/ATL/WTL) as opposed to C++ in VS 6.0?
2. Is there a difference between VC++ NET Standard and the professional version when it comes to MFC/ATL/WTL programming?
I would greatly appreciate any advice.
|
|
|
|
|
Perhaps I can offer some answers..
As for the first question, the VS .NET version, especially the 2003 which I have, offer a much more flexible and working integration systems that simplify coding quite much. For example, the clumsy ClassWizard has been removed, and instead, every MFC class is considered a standard C++ class, and there is a 'properties' bar for it from which you can override virtual functions, create Windows message and event maps and so on. Generally speaking, my coding time has improved some and I can now focus more on the content itself as I don't need to worry about buggy CW files or missing virtual functions, which was a common error during the VS 6.0 times. I was constantly deleting and remaking the CW files.
Also, the VS .NET is much more flexible. The Class Bar has improved a lot, making it possible to e.x. add your own classes to the list of MFC base classes. Like, if you were to derive a custom control and would like to derive again from this control, you can move the files in question to a special directory, and then you can create descendants, override virtual functions and do custom implementation easily by using the Class View and it's properties-page.
For the second question, no, not really. The MFC/ATL/WTL libraries shipped with either the Standard or Professional editons are the same, version 7. The biggest source of differencies comes from the functionality of the IDE and the optimization/customization options of the compiler/linker. The Professional version compiler, for example, is capable of doing much greater level of optimization routines and compile-time code manipulation than the Standard version one.
As a final note, if you have enough money to invest, I suggest you go for the Professional, or even better, the Architect version. You can read more about the differences between seperate versions from the VS .NET homepage located in here[^].
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi,
Does any one know what is a TBCD ( Telephonic Binary Coded Decimal ) field, and how we can decode it. I have a TBCD field of length 5 in a binary file, and would like to decrypt it.
Best Regards
Jagadeesh
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Hello guys,
I have just moved into W32's serial communication, it is to be written to talk to a printer device via standard RS232. I have used basic functions such as CreateFile(), ReadFile() and WriteFile(). It all seems to be straight-forward when the communication will always be firstly WriteFile() to the device and then expect getting a response using ReadFile(). The tranmission from the device will always end with an EOT (0x04) so I'd use while loop on the ReadFile() until the EOT is received. By doing this, I somehow need a 'timeout' implementation within (say the loop breaks and gives an timeout error message after 3 seconds) otherwise it is possible the loop goes forever...Now the problem is I could not think of a way to go about inserting a timeout. Could it be done using SetTimer() etc?
BTW, I have placed the whole serial communication stuff in a separate worker thread so it does not interrupt the front GUI.
Can anyone help me with this?
Would be very much appreciated.
Thanks
|
|
|
|
|
You could, for example, create a global-level boolean variable, if you're not using classes. Then create a timer for the thread, and in the thread's message processing function, handle the WM_TIMER event. When the timer event is launched, the boolean is set to TRUE, which causes the while loop to exit.
Another option would be to use the Sleep function. This function will cause a thread to suspend until the time is elapsed, then continue the program execution from the next line of code. You could create a local variable, say an integer, which would go from 0 to 3, and during each while-loop iteration, the port is tested, then the thread sleeps for 1 second and increases the integer. The while-loop will automatically exit after 3 seconds.
The latter implementation only attempts to read the port at 1 second intervals, so it is not entirely reliable. If you need a more reliable system, decrease the sleep time and increase the iteration amount. An amount of going from 0...100 would already offer you the possibility to check the port at 30 ms intervals, if you aim for a 3 second time-out.
The advantage of the sleep function is the lack of the timer: there will be no extra message-processing needed. Know, however, that during the sleep time, the thread will not process any messages at all.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti Keskinen wrote:
Another option would be to use the Sleep function.
Thnaks for the suggestions, Antti.
the sleep function came upon my head as well but I am not entirely sure if the function works in multi-threaded application? But from your answer, it looks like if the sleep is placed in the thread process call, it then will only suspend the thread process, not entire program, correct? In addition, I could not seem to locate sleep() or usleep() functions in my MFC apps? they give me undeclared identifier.
Finally, it is not really Visual C++ related. But how do I test my serial comm program is working using only the PC? Should I be able to see the sending string on HyperTerminal, if the program WriteFile() to the specified port (given it's done correctly)?
Thanks again
|
|
|
|
|
According to the MSDN reference:
The Sleep function suspends the execution of the current thread for at least the specified interval.
So, yes, it works in a multi-threaded application: it suspends the execution of the thread from which it is called. As for the reason of why you were unable to call the function from your programs: make sure you are calling the function Sleep() , not sleep() . The first one exists, the latter one doesn't. You must also include windows.h header file and link with Kernel32.lib library.
The serial ports are connectionless: they do not care to where they are connected, as long as a connection exists and the software using the communications configures the ports correctly. So, I believe the most easiest way is to utilize two serial ports. Most computers nowadays have two serial ports. Just obtain a cross-connected serial link cable (or do one yourself), then interconnect two of your computer's serial ports. Make your comms program write to the first port, and put some terminal program, e.x. HyperTerminal, to listen on the receiving end. Just remember to set the terminal program's port attributes correctly, otherwise you might get no results at all.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|