mfc >> Noobish question about DBGrid and .mdb files

by Phlimm » Sat, 22 Nov 2003 08:25:18 GMT

I have VC++ 5.0. There is a form with an ODBC Class for Access tables.
When the form executes, what I am looking for is a "tableframe" type of
object that will be linked to the .mdb file and display the table contents
on the form. Ideally, the user could add, edit and delete records as well
as move around the table. Is this a DBGrid type ActiveX? I plopped down a
DBGrid and looked at the properties, it says DataMode is 0-Bound. But then
the DataSource is <Not bound to a DataSource> and that is the only option
in the drop down.

Is this an object that needs to be created and defined all along the way or
is there a "tableframe" object (ActiveX or not) that can be assigned to the
database in this manner?

Thx In Advance


mfc >> Noobish question about DBGrid and .mdb files

by Clive Minnican » Tue, 25 Nov 2003 01:43:10 GMT


ou need to create an ADO Data Control first... See the doc below taken from
Visual C++ 6 online help (Using ADO Databinding in Visual C++). I started
off using the DBGrid control but I now prefer to populate a CListCtrl
manually from a CRecordset because you get a lot more control. It's not as
hard as it sounds either - just read up on CDatabase and CRecordset and it
will soon make sense. If you are really stuck I will provide some sample
code.

Hope this helps,
Clive.

=========================================================

Using ADO Databinding in Visual C++
Using ADO databinding in Visual C++ requires the following steps.

a.. Add an ADO Data Control.


b.. Point to a data source.


c.. Specify the record source (SQL query or data retrieval language).


d.. Add an ADO data-bound control.


e.. Connect the data-bound control to an ADO Data Control.


f.. Select the fields to bind to the ADO Data Control's record source.
To use ADO databinding in Visual C++

1.. Create an MFC Dialog application or MFC Formview application using the
MFC AppWizard.


2.. Add the Microsoft ADO Data Control to the dialog box; see Inserting
the Control into a Visual C++ Application.


3.. Point the ADO Data Control to your OLE DB data source.
1.. Right-click on the ADO Data Control and select Properties from the
shortcut menu.


2.. On the Control tab, select the Use Connection String. You can use
the supplied provider or you can delete it.


3.. Select Build. If you deleted the provider from Use Connection
String, you will now be able to define one. After you define the provider,
access the properties of the ADO Data Control again and select Build again
to continue.
If a provider is defined in Use Connection String before you select
Build, you will now be able to define the data link properties. This
displays the DataLink Wizard.

4.. Change the Provider if necessary, and define Location and Data
Source values, as appropriate for your provider. For example, if you are
using a SQL Server provider, Location specifies the database server and Data
Source specifies the database. If you are using an ODBC provider, the Data
Source corresponds to the ODBC DSN.


5.. Select the Authentication tab and set values for User Name and
Password, if required by the data source.


6.. Return to the Connection tab and click Test Connection to test the
data source. Scroll to the end of the Results window to see if the test
passed. If it failed, check the configuration of your data source. Common
errors include invalid passwords and incorrect values for the Location and
Data Source fields.


7.. Exit the DataLink Wizard and return to the property sheet for the
ADO Data Control.
4.. In the RecordSource tab, enter a query into the Command Text (SQL).
The data-bound controls can bind to the results of this query. The query
will usually be SQL. However, some OLE DB providers do not use SQL.


5.. Set any other ADO Data Control properties as needed and close the
property sheet for the ADO Data Control.


6.. Add a data-bound control. For example, add the DataGrid control. (Do
not confuse the DataGrid control with the RDO DBGrid control.)


7.. Set the DataGrid's properties.
1.. Right-click on the DataGrid and select Properties from the shortcut
menu.


2.. Select the All tab and set the DataSource property to the ADO D


mfc >> Noobish question about DBGrid and .mdb files

by Clive Minnican » Tue, 25 Nov 2003 01:47:41 GMT

orry I forgot - DBGrid controls are for RDO - DataGrid controls are for
ADO - in my experience DataGrid controls are better.

"Clive Minnican" < XXXX@XXXXX.COM > wrote in message news:...
from
the
Data
shortcut
contents
well
down
option





Noobish question about DBGrid and .mdb files

by Phlimm » Tue, 25 Nov 2003 12:33:51 GMT

live -

Thanks for the reply. Could you throw some sample code in here, or email
me? I tried to follow up via email to you but it bounced back.

Thanks

Phlimm



Clive Minnican babbled on for HOURS on 24 Nov 2003:




Similar Threads

1. Noobish C# question about XML parsing... - CSharp/C#

2. Simple noobish question

I am having a problem with a small bit of code. I can't figure out why
it won't work. Here:


//code:
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>

using namespace std;

int main()
{
	ifstream file_in;
	ofstream file_out;
	string word_in;
	int old_total = 0;
	int new_total = 0;
	int x = 0;

	file_in.open("words.list");
	file_out.open("words.out");

	while ( !file_in.eof() )
		{
			getline(file_in, word_in);
			old_total++;
			int good = 0;
			for ( int i = 0; i < word_in.size(); i++ )
				{
					if ( isalpha( word_in[i] ) != 0)
						 {
							 continue;
						}
					else
						 {
							 x = 1;
							 break;
						}
				}
			if ( x == 0 )
				{
					file_out << word_in << endl;
					new_total++;
				}
			else
				{
					continue;
				}
		}
	cout << old_total << " lines in the original file." << endl;
	cout << new_total << " lines in new file." << endl;
	cout << old_total - new_total << " lines of difference." << endl;

	return 0;
}
//code


All this is supposed to do is run through a list of words from one
file and put the one that only have the standard 26 letters of the
English alphabet into another file. It works fine until it hits the
first word with a non-english character, at which time it finishes and
exits. The output is this:

72411 lines in the original file.
589 lines in new file.
71822 lines of difference.

Obviously the new file should have a whole lot more lines than that.
At line 590 is the word Asunci. It is such a minor thing but it is
driving me up a wall none the less. Any comments would be much
appreciated.

Thanks

3. file deletable?, shortcuts, .mdb file backup - CSharp/C#

4. Change a MS Access file (mdb) to a MS Project file (mpp)

I hope this is the right forum.  I plan to use VC++ and MFC to manipulate the 
file formats available with MS Project so you tell me.

First I should ask if anyone knows if there is a C++ class library out there 
for MS Project?  I need to change a Project file saved as an Access database 
back to a Project file format.  (i.e. Start with a MPP file, change it to a 
MDB file and then back to a MPP file).

I start with a Microsoft Project file that is saved with a Microsoft Access 
file format.  The Access file lives on my web server.  From a browser, I can 
update the Access file from a data entry screen using ASP (Active Server 
Pages).  Once the Access file is updated with new or modified data, I want to 
then save it 
back as a Microsoft Project file again which will also live on my web server. 
 

With my newly saved Microsoft Project file I want to then use Adobe's SDK 
and save the Microsoft Project file as a PDF file allowing it to be viewed 
from any web browser.   In so doing I have gone around many of the needs for 
running Microsoft Project Server which leaves out alot of info found on the 
desktop when the file is viewed from a browser.  A PDF file on the other hand 
shows everything and very well I might add.

Thanks in advance for any insight...

5. mdb access question under win2003

6. distributing an mdb file with custom C# application

Hi all,

I want to distribute an mdb file with my custom made app written in C#, for 
use as its data store, but I am really unsure of how this affects the 
licensing. I have read the other posts here relating to licensing issues, but 
I can't find an answer to this one.

I have legitimate copies of Access 2003, Visual Studio 2005, etc. so I am 
sure I am in order making the mdb file itself, (and the app in Visual Studio 
of course).

However, can I distribute the mdb file with the application, which would 
only be opened by my application, and not Access, to add/query/delete items 
from it?

I have tried reading the EULA but I must confess I did not really understand 
it. 

Thanks for any help on this one,
regards,
Gary

(Hope this is the right place for this query - apologies if not.)

7. create mdb file, c++ atl, access

8. Include MDB file in Solution

Hi, i include an Access Db in the solution of my project; now how can
i connect to DB?