Click here to Skip to main content
15,917,645 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHelp required !! Pin
Stephan Poirier10-Feb-03 18:32
Stephan Poirier10-Feb-03 18:32 
GeneralCreateDialog failure Pin
Anonymous10-Feb-03 17:07
Anonymous10-Feb-03 17:07 
GeneralI want to Create a Process with CreateProcessAsUser from as PrintMonitor running under the System Account Pin
Karl Bauer10-Feb-03 16:14
Karl Bauer10-Feb-03 16:14 
QuestionDetecting first run ? Pin
autekre10-Feb-03 15:57
autekre10-Feb-03 15:57 
AnswerRe: Detecting first run ? Pin
ColinDavies10-Feb-03 17:56
ColinDavies10-Feb-03 17:56 
GeneralReplacing the MFC WinMain. Pin
Daeriel10-Feb-03 14:22
Daeriel10-Feb-03 14:22 
GeneralRe: Replacing the MFC WinMain. Pin
Alvaro Mendez11-Feb-03 5:36
Alvaro Mendez11-Feb-03 5:36 
GeneralRe: Replacing the MFC WinMain. Pin
Daeriel11-Feb-03 12:07
Daeriel11-Feb-03 12:07 
GeneralExe size Pin
User 988510-Feb-03 12:17
User 988510-Feb-03 12:17 
GeneralRe: Exe size Pin
Chris Losinger10-Feb-03 13:22
professionalChris Losinger10-Feb-03 13:22 
GeneralRe: Exe size Pin
User 988511-Feb-03 13:46
User 988511-Feb-03 13:46 
GeneralRe: Exe size Pin
Chris Losinger11-Feb-03 14:19
professionalChris Losinger11-Feb-03 14:19 
GeneralRe: Exe size Pin
Mike Nordell10-Feb-03 14:58
Mike Nordell10-Feb-03 14:58 
GeneralRe: Exe size Pin
Neville Franks10-Feb-03 23:53
Neville Franks10-Feb-03 23:53 
QuestionCan someone give me examples of using these SQL statements?? Pin
IrishSonic10-Feb-03 12:04
IrishSonic10-Feb-03 12:04 
AnswerRe: Can someone give me examples of using these SQL statements?? Pin
xxhimanshu10-Feb-03 17:35
xxhimanshu10-Feb-03 17:35 
hi,
CDatabase m_db; //declare database object
CRecordset m_EmpTable; // declare recordset for employee table

//////////////////////////////////////////////////////////////////////////////
// Open connection to database ORACLE01 (must be defined as
// data source in ODBC)
TRY{
m_db.OpenEx( "DSN=ORACLE01;UID=scott;PWD=tiger" , CDatabase::noOdbcDialog );
}
CATCH( CDBException, dbe ){
MessageBox( dbe->m_strError );
}
END_CATCH

//////////////////////////////////////////////////////////////////////////////
// Insert new employee record into table Emp
TRY{
m_db.ExecuteSQL( "INSERT INTO EMP VALUES(10, 'John','Brown','Chicago')" );
}
CATCH( CDBException, dbe ){
MessageBox( dbe->m_strError );
}
END_CATCH

//////////////////////////////////////////////////////////////////////////////
// Retrieve records from table Emp based on query
CString id;
CString fname;
CString lname;
CString city;

m_EmpTable.Open( CRecordset::dynaset, "SELECT * FROM EMP" ); // open recordset

while( !m_EmpTable.IsEOF( ) ) // retrieve records one by one
{
m_EmpTable.GetFieldValue( (int)0, id );
m_EmpTable.GetFieldValue( 1, fname);
m_EmpTable.GetFieldValue( 2, lname );
m_EmpTable.GetFieldValue( 3, city );

// do something with data

m_EmpTable.MoveNext(); // move to the next record
}
or you can do it like this..

CAccountRecord rs(&db);

rs.Open( CRecordset::snapshot );

rs.AddNew();
rs.m_NAME = "Becky Dugan";
rs.m_ADDRESS = "Bustins, ME 01443";
rs.m_ID = 33;
rs.m_AMOUNT = 100000;

if(!rs.Update( )){
cout << "Record not added; no field values were set.";
return FALSE;
}

rs.Close();

m_EmpTable.Close(); // close recordset
// How to do an UPDATE
/////////////////////////////////////////////////////////
rs.Open( CRecordset::snapshot,
_T( "select * from scott.account where id=42" ));

rs.MoveFirst();
rs.Edit();
rs.m_NAME = "Robert Dugan";

if(!rs.Update( )){
cout << "Update failed." << endl;
return FALSE;
}

rs.Close();

Verify that the update happened by using sqlplus:

// How to do a DELETE
////////////////////////////////////////////////////////
rs.Open( CRecordset::snapshot );
rs.MoveLast();
rs.Delete();
rs.Close();

i hope this is done now..Cheers


Himanshu
GeneralUsing askey in a file Pin
proprogram10-Feb-03 12:01
sussproprogram10-Feb-03 12:01 
GeneralRe: Using askey in a file Pin
Mike Nordell10-Feb-03 12:29
Mike Nordell10-Feb-03 12:29 
GeneralAccessing data/file when app launched from attachment Pin
Dr Soong10-Feb-03 11:43
Dr Soong10-Feb-03 11:43 
GeneralRe: Accessing data/file when app launched from attachment Pin
JoeSox10-Feb-03 12:09
JoeSox10-Feb-03 12:09 
GeneralRe: Accessing data/file when app launched from attachment Pin
Mike Nordell10-Feb-03 15:08
Mike Nordell10-Feb-03 15:08 
QuestionHow to get my DNS server ? Pin
Yasen Georgiew10-Feb-03 11:05
Yasen Georgiew10-Feb-03 11:05 
AnswerRe: How to get my DNS server ? Pin
Rene De La Garza10-Feb-03 11:37
Rene De La Garza10-Feb-03 11:37 
GeneralNT Service would not start...! Pin
Prabhakar10-Feb-03 10:57
Prabhakar10-Feb-03 10:57 
GeneralRe: NT Service would not start...! Pin
palbano10-Feb-03 11:06
palbano10-Feb-03 11:06 

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.