Click here to Skip to main content
15,898,708 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Insert an image in dialog box Pin
Atif Mushtaq16-Mar-04 18:53
Atif Mushtaq16-Mar-04 18:53 
Generalproblem with strings greater then 32ks Pin
safee ullah16-Mar-04 17:53
safee ullah16-Mar-04 17:53 
GeneralRe: problem with strings greater then 32ks Pin
David Crow17-Mar-04 2:54
David Crow17-Mar-04 2:54 
GeneralRe: problem with strings greater then 32ks Pin
safee ullah17-Mar-04 3:20
safee ullah17-Mar-04 3:20 
GeneralRe: problem with strings greater then 32ks Pin
David Crow17-Mar-04 7:24
David Crow17-Mar-04 7:24 
GeneralRe: problem with strings greater then 32ks Pin
kalyan_reddy17-Mar-04 22:55
kalyan_reddy17-Mar-04 22:55 
GeneralStep by Step Simple Database Pin
MeterMan16-Mar-04 16:36
MeterMan16-Mar-04 16:36 
GeneralRe: Step by Step Simple Database Pin
Terry O'Nolley16-Mar-04 17:02
Terry O'Nolley16-Mar-04 17:02 
This isn't going to be an MFC "purist's" response.
These steps are simply the simplest ways to get a database thing going.
They do not rely on the App Wizard to do anything. They do not tie member variables to data fields.

To access a database that has an ODBC mapping to it, do the following:
1) #include <afxdb.h> in your source file
2) To pull records from your database, do the following:

<br />
CDatabase db;<br />
db.OpenEx("XXX-ODBC DATASOURCE MAPPING NAME GOES HERE-XXX");<br />
CRecordset rs(&db);<br />
CString QueryString;<br />
CString data;			   // holds data from database<br />
<br />
QueryString = "SELECT * FROM tablename"; // SQL query goes here<br />
<br />
rs.Open(AFX_DB_USE_DEFAULT_TYPE, QueryString);<br />
<br />
// this loop will execute once for each record returned by the query in QueryString<br />
while(! rs.IsEOF())<br />
{<br />
   rs.GetFieldValue("FieldName", data);      // Tell it which field you want assigned to what variable<br />
   rs.MoveNext();  // move to the next record<br />
<br />
   // now do whatever you want with the value in data - it now contains what was in the database field specified in the GetFieldValue call<br />
}<br />
<br />
rs.Close();<br />
db.Close();<br />




I'm going to live forever or die trying
Rangers Lead The Way

GeneralRe: Step by Step Simple Database Pin
Steve S16-Mar-04 23:01
Steve S16-Mar-04 23:01 
Generalmulti-threaded socket app Pin
Roman Nurik16-Mar-04 15:02
Roman Nurik16-Mar-04 15:02 
GeneralRe: multi-threaded socket app Pin
Aaron Schaefer17-Mar-04 9:41
Aaron Schaefer17-Mar-04 9:41 
Generaldbserverenum Pin
halblonious16-Mar-04 14:29
halblonious16-Mar-04 14:29 
GeneralRe: dbserverenum Pin
l a u r e n16-Mar-04 15:48
l a u r e n16-Mar-04 15:48 
GeneralRe: dbserverenum Pin
David Crow17-Mar-04 2:59
David Crow17-Mar-04 2:59 
GeneralRe: dbserverenum Pin
halblonious19-Mar-04 12:21
halblonious19-Mar-04 12:21 
GeneralRe: dbserverenum Pin
David Crow22-Mar-04 2:07
David Crow22-Mar-04 2:07 
GeneralRe: dbserverenum Pin
halblonious24-Mar-04 7:52
halblonious24-Mar-04 7:52 
GeneralRe: dbserverenum Pin
David Crow24-Mar-04 7:57
David Crow24-Mar-04 7:57 
GeneralRe: dbserverenum Pin
halblonious25-Mar-04 9:30
halblonious25-Mar-04 9:30 
GeneralModeless Dialog - Removing the Cancel X in Title Bar Pin
jerry1211a16-Mar-04 13:24
jerry1211a16-Mar-04 13:24 
GeneralRe: Modeless Dialog - Removing the Cancel X in Title Bar Pin
Navin16-Mar-04 14:38
Navin16-Mar-04 14:38 
GeneralRe: Modeless Dialog - Removing the Cancel X in Title Bar Pin
Prakash Nadar16-Mar-04 15:08
Prakash Nadar16-Mar-04 15:08 
GeneralRe: Modeless Dialog - Removing the Cancel X in Title Bar Pin
jerry1211a16-Mar-04 15:26
jerry1211a16-Mar-04 15:26 
GeneralRe: Modeless Dialog - Removing the Cancel X in Title Bar Pin
jerry1211a16-Mar-04 15:29
jerry1211a16-Mar-04 15:29 
GeneralAuto Tracing Tool Pin
autodebug16-Mar-04 12:19
autodebug16-Mar-04 12:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.