Click here to Skip to main content
15,914,322 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Read char with X/Y axes? Pin
Lord Kixdemp5-Feb-06 12:51
Lord Kixdemp5-Feb-06 12:51 
GeneralRe: Read char with X/Y axes? Pin
PJ Arends5-Feb-06 13:23
professionalPJ Arends5-Feb-06 13:23 
GeneralRe: Read char with X/Y axes? Pin
Lord Kixdemp5-Feb-06 16:30
Lord Kixdemp5-Feb-06 16:30 
GeneralRe: Read char with X/Y axes? Pin
Lord Kixdemp8-Feb-06 10:55
Lord Kixdemp8-Feb-06 10:55 
QuestionApplication hangs when interrupted Pin
Joel McAlduff5-Feb-06 5:46
Joel McAlduff5-Feb-06 5:46 
AnswerMessage Closed Pin
5-Feb-06 8:44
ddmcr5-Feb-06 8:44 
GeneralRe: Application hangs when interrupted Pin
Joel McAlduff5-Feb-06 8:56
Joel McAlduff5-Feb-06 8:56 
QuestionRetrieving data from an ODBC data source Pin
SWDevil5-Feb-06 4:26
SWDevil5-Feb-06 4:26 
Hi,

I need to write an application that:
1. opens a database (I connect through ODBC)
2. retrieves data from a table, using an SQL query
3. enters the retrieved data into a table in a different database

So far, I wrote the following code for steps 1 and 2:

CDatabase srcDb;
if (srcDb.Open(NULL))
{
m_sDbName = srcDb.GetConnect(); //m_sDbName is a variable of type CString
UpdateData(FALSE);
}

CRecordset rs(&srcDb);
CString strSQL;
strSQL = "SELECT * FROM table1";

rs.Open(CRecordset::snapshot, strSQL, CRecordset::readOnly);
rs.Close();


Everything works OK, (the database is connected), but when it gets to the row:
rs.Open(CRecordset::snapshot, strSQL, CRecordset::readOnly);
the application crashes, and I don't understand why...

Is this the right syntax for connecting to a database and retrieving data from a table? Can someone maybe attach some source code, so I could compare...

Another question - after the row: rs.Open(CRecordset::snapshot, strSQL, CRecordset::readOnly); is executed, how do I read the data that was retrieved by the SQL query? is it in the recordset object?

Note: I am using Visual C++ 2003.
AnswerRe: Retrieving data from an ODBC data source Pin
Joel McAlduff5-Feb-06 4:44
Joel McAlduff5-Feb-06 4:44 
GeneralRe: Retrieving data from an ODBC data source Pin
SWDevil5-Feb-06 4:52
SWDevil5-Feb-06 4:52 
GeneralRe: Retrieving data from an ODBC data source Pin
Joel McAlduff5-Feb-06 5:22
Joel McAlduff5-Feb-06 5:22 
GeneralRe: Retrieving data from an ODBC data source Pin
SWDevil5-Feb-06 20:55
SWDevil5-Feb-06 20:55 
AnswerRe: Retrieving data from an ODBC data source Pin
David Crow7-Feb-06 2:54
David Crow7-Feb-06 2:54 
GeneralRe: Retrieving data from an ODBC data source Pin
SWDevil7-Feb-06 5:25
SWDevil7-Feb-06 5:25 
GeneralRe: Retrieving data from an ODBC data source Pin
David Crow7-Feb-06 5:34
David Crow7-Feb-06 5:34 
QuestionVisual Studio 2005 Standard - MFC? Pin
Dominik Reichl5-Feb-06 2:08
Dominik Reichl5-Feb-06 2:08 
AnswerRe: Visual Studio 2005 Standard - MFC? Pin
Jack Puppy5-Feb-06 3:21
Jack Puppy5-Feb-06 3:21 
QuestionDetecting flash animation and pop-ups Pin
llp00na5-Feb-06 2:01
llp00na5-Feb-06 2:01 
QuestionRotation text Pin
duvaft4-Feb-06 23:08
duvaft4-Feb-06 23:08 
AnswerRe: Rotation text Pin
Eugene Pustovoyt5-Feb-06 0:21
Eugene Pustovoyt5-Feb-06 0:21 
AnswerRe: Rotation text Pin
EXTEIDE5-Feb-06 1:23
EXTEIDE5-Feb-06 1:23 
GeneralRe: Rotation text Pin
Eugene Pustovoyt5-Feb-06 2:14
Eugene Pustovoyt5-Feb-06 2:14 
GeneralRe: Rotation text Pin
EXTEIDE5-Feb-06 3:41
EXTEIDE5-Feb-06 3:41 
AnswerRe: Rotation text Pin
Stephen Hewitt5-Feb-06 20:13
Stephen Hewitt5-Feb-06 20:13 
QuestionHow to go about porting to windows? Pin
Chintoo7234-Feb-06 22:42
Chintoo7234-Feb-06 22:42 

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.