|
A brief introduction of database programming with ODBC:
The database programming model in MFC, for example, consists of clearly seperated elements. Firstly, you have a database object. This object represents the connection to a database. The database itself can be of any type (MySQL, Oracle, MS SQL), as databse objects are bound to the databases through either the database driver or a data source definition.
Data source definitions are entries in ODBC Manager. They specify the database driver used, login name, password, target database and any necessary flags or settings. You can use the driver directly through a database object as well.
Next step up, we have a recordset object. A recordset object represents a query to a database: a collection of one or more SQL statements and a set of internal variables to hold the response from these statements. When you construct a recordset object, you can specify a database object reference for it. This means that any statements you execute and the results of those statements are handled in the context of this very database.
For the recordset objects, they contain a FieldExchange object, which is responsible for doing the field exchange between the results received from the recordset and the internal variables you have specified. Overriding the member function 'DoFieldExchange' allows you to specify how the returning results are stored.
More information is available in the MSDN Reference for classes CDatabase and CRecordset. Also, there is a good quantity of different articles available here at CodeProject. This[^] is a good place to start: look articles which have a 'Beginner' level specification next to them. These articles will help you get started. The rest is experiencing and testing.
The most easiest way in Visual Studio .NET 2003 is to add a MFC ODBC Database consumer class to your project. The wizard will help you through then.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
thanks for the info.
your suggestion is highly appreciated!
|
|
|
|
|
Hello guys,
My machine has XP OS, .net platform and VC7 installed. If i create an application that uses GDI+, then will that application work on win2000 where there is no .net platform installed.
What all things do i need to do for that application to work on win2000.
Can any one answer me who has pratically confirmed it. As i have only one machine and no more room for win2k on my harddisk, i am not able to test it.
Thanx in advance.
The World is getting smaller and so are the people.
|
|
|
|
|
GDI+ is a redistributable component and can be downloaded here[^].
For Platform SDK updates and redistributable components, see Platform SDK Update[^].
|
|
|
|
|
I am wondering how I could read in a file without neccessarily storing it, in order to just find the length of the file so that I can create an array the specific length of the file. Thanks
|
|
|
|
|
What do you mean without storing it?
1. There is a structure stat and a function _stat (header types.h, refer MSDN)
2. You can use the FindFirstFile function to get the file info structure which contains the file attributes (MSDN again)
These two ways get you the file size without having to open in explicitly.
Hope this helps
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
|
In my vc++ codes, I must use the filter of the Object recordset to filter some records, I get the query term from a EditBox, but when the term include the character "%", the filter seems to meet some problem in deal with the "%",
What should I do, some body tell me how please.
What's more, when the operater is ">" or ">=", the filter meet the same error.
Could some one tell me why ?
Thanks advance.
|
|
|
|
|
Most databases require special characters to be escaped if they are part of sql. For some databases you can choose you escape sequence others have predefined '\'....
Characters '[,=+-&%#!@">
|
|
|
|
|
I am trying to figure out a way to create a simple toolbar for IE, or MOZILLA or both..
All I am looking for is to hyperlink to 2 different websites. I am trying to get 2 Main headings for each site, and a drop down list under each for different pages on that site, can anyone help, I am a 26 y/o NEWBEE to programming.
I am hoping to get it too look like this:
Main Topics as if this was the toolbar and drop down menus
CSRA Light Flyers Trenton Flyers
Home Home
Pictures News
News Pictures
Thanks!!
Eric Marenyi
|
|
|
|
|
I do not completely understand what you wanna achive.
You can surely extend Internet Explorer but only with the following things:
1.New Toolbar buttons (but no dropdown possible)
2.New Menu items (very restricted, only under Tools, and Help)
3.Hor or vertical Explorer bars (they look like the treeview in Window Explorer on the left but anything not only trees can be implemented on them)
If you click on the "History" or "Favorites" buttons such Explorer bars are shown.
That's it, no other tricks.
For further details look in MSDN under "Browser Extensions" they are -surprisingly- very well documented.
Peter Molnar
|
|
|
|
|
|
Which is the simplest way to terminate a dialog-based application?
|
|
|
|
|
1.The simplest is: clicking on the close button on the right upper corner with the mouse.
2.Second simplest: DestroyWindow() (from your app);
Peter Molnar
|
|
|
|
|
)Sorry, I missed some words in my question - I meant how one application can terminate another one...
|
|
|
|
|
|
Click the the X???
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
O, really? Thanks! It's my mistake I didn't ask the right question - what I meant was how one application can terminate another one.
|
|
|
|
|
I figured so...but the answer is fairly trivial, so I figured I'd just be a smart a$$ and let someone else tell you.
Cheers
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
if you know the title of that window, use this:
LPSTR name="the_window_title";
HWND hWnd = ::FindWindow(NULL,name);
::SendMessage(hWnd, WM_CLOSE, 0, 0);
|
|
|
|
|
The best way is to send WM_CLOSE message at any time
|
|
|
|
|
AfxGetMainWnd()->PostMessage(WM_CLOSE, 0, 0);
Fast.
Riccardo.
|
|
|
|
|
Is it possible to restart my dialog application from within or should I create an outside object to close it and then to start it again?
|
|
|
|
|
If your application lives just in an *.exe there isn't a possibility, but if in a *.dll there is.
You load your own .dll from an *.exe, when the *.dll attaches to the *.exe the reason for call in DllMain is DLL_PROCESS_ATTACH. Depending upon value of dwReason you can start your code.
If your process starts, your *.exe is shown in the task manager (with the *.dll linked to it), and it can be killed from there. In this case your DllMain gets called again with reason DLL_PROCESS_DETACH. From here you have to do a ShellExecute on your *.exe, and your process with the linked *.dll starts again.
Peter Molnar
|
|
|
|
|
You basically need two exe files, say, A and B. Now you want to restart A "within" A, you simply let A do the following:
1, Launch B via a call to ::ShellExecute .
2, Terminate itself.
At this point B has been launched and A has been terminated. Now, what B does are the following:
1, Wait a few seconds by using a timer. This is usually necessary because A may need some time to cleanup, i.e., de-allocate resources, clean files, whatever, etc.
2, Launch A via a call to ::ShellExecute .
3, Terminate itself.
So now your A is "restarted".
|
|
|
|