|
See if this example helps.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
here is an example for open and read a database *.mdb. Hope is helpful...
CString File = "database.mdb";
COleVariant var;
CDaoDatabase *db = null;
CDaoTableDef *TabDef = null;
CDaoRecordset *rec = null;
try
{
db = new CDaoDatabase(NULL);
db->Open(File, FALSE, FALSE, _T(""));
TabDef = new CDaoTableDef(db);
TabDef->Open("TABELLA1");
rec = new CDaoRecordset(db);
rec->Open(TabDef, dbOpenTable, 0);
rec->MoveFirst();
while( !rec->IsEOF() )
{
rec->GetFieldValue("CAMPO1", var);
rec->MoveNext();
}
rec ->Close();
TabDef->Close();
db ->Close();
}
catch( CDaoException* e )
{
GestErroriDAO(e, db, TabDef, rec);
e->Delete();
}
delete rec;
delete TabDef;
delete db;
|
|
|
|
|
Did you search on the codeproject?
|
|
|
|
|
i created a modeless dialog box to my network application tool
when i right click on objects and opening the dialog box it is creating in a new seperate window plz help
i created like this
m_pEditPersonalityDlg->Create (IDD_PERSONALITY_DIALOG, AfxGetMainWnd());
|
|
|
|
|
Have a look at the dialog's styles in the resource editor. Have you told it to be a child window? And you may or may not want to change the border style as well.
Iain.
Iain Clarke appears because CPallini still cares.
|
|
|
|
|
ya irain its a chaild window i checked in resource editor style is pop up and border is dialog frame
if i keep style as child its not working its creating differently
i.e back side of the main app
|
|
|
|
|
Hi,
Also try using AfxGetApp()->m_pMainWnd instead of AfxGetMainWnd().
thanks ,
Nitheesh
|
|
|
|
|
No Niteesh not working with that same result
its unsolved problem for me since long time
|
|
|
|
|
girishchi@gmail.com wrote: ...it is creating in a new seperate window...
Instead of what?
The owner of a window is not necessarily the same as its parent. See here for more.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ya i got it we have to add setparent function in OnInit function
|
|
|
|
|
i have some problm to insert data into excel sheet. i hv configure the DSN name and the Workbook and also clear the read only option. i can read dat from that workbook as usual. But when i write the data then data is inserted only when , that worksheet is opened in task bar. data is not inserted when that worksheet is not opened in task bar. i am not able to find reason for that event.
i am sending the sample code for executing a query for excel sheet.
BOOL ExcuteStmtUpdate(char* Query)
{
SQLRETURN status;
int rc=-1;
SQLHSTMT StatementHandle;
long Roll;
SDWORD sdwALen;
int i;
//allocate statment handle
status = SQLAllocHandle (SQL_HANDLE_STMT,UpdateDBC.m_Connection,&StatementHandle);
if(status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
{
SQLFreeHandle (SQL_HANDLE_STMT, StatementHandle);
return false;
}
status = SQLPrepare(StatementHandle,(unsigned char*)Query,strlen(Query));
if(status == SQL_SUCCESS || status == SQL_SUCCESS_WITH_INFO)
{
status=SQLBindCol(StatementHandle, 1, SQL_C_SLONG,(PTR)&Roll, sizeof(Roll), &sdwALen);
//SQLExecute call
status = SQLExecute(StatementHandle);
if(!(status == SQL_SUCCESS || status == SQL_SUCCESS_WITH_INFO))
{
SQLFreeHandle (SQL_HANDLE_STMT,StatementHandle);
return false;
}
for (i = 1; (rc = SQLFetch(StatementHandle)) == SQL_SUCCESS; i++)
{
printf("%d ",Roll);
}
status=SQLEndTran(SQL_HANDLE_ENV,UpdateDBC.m_EnvironmentHandle, SQL_COMMIT);
}
else
{
SQLFreeHandle (SQL_HANDLE_STMT, StatementHandle);
return false;
}
SQLFreeHandle (SQL_HANDLE_STMT, StatementHandle);
return true;
}
|
|
|
|
|
here is a technique but iam not sure weather it is useful for your requirement.
simply do the file operations.
FILE *fp;
fp=fopen("C:\\test.xls","w");
fprintf(fp,"data1\n");
fprintf(fp,"data2\n");
fclose(fp);
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
modified on Thursday, April 10, 2008 6:40 AM
|
|
|
|
|
Are you kidding ? Do you know that excel files are binary files ?
|
|
|
|
|
all this i have done in my program. data is inserted when excel sheet is opened
is it possible or not, to insert data into excelsheet without MFC and Com component?
|
|
|
|
|
There are multiple layers of ignorance in this post. Perhaps the easiest to address is that C file handling is ugly as sin, I would never use it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: Perhaps the easiest to address is that C file handling is ugly as sin, I would never use it.
So do you use D or E file handling?
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
Did you make a test of such a technique?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
yes all this thing written in question are done thru my program
|
|
|
|
|
And you program really inserts values into Excel cells?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
values are inserted when excel sheet is opened in task bar otherwise not.
|
|
|
|
|
You're simply writing a text file (that Excel can import, of course). But what if you access that way an existing Excel document?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
i am trying to solve this problm from 5 days. But i can't find the solution or hint for this problm. if we can read data when excel sheet is not opened in task bart then why not write. if u have solution then please help me.
|
|
|
|
|
Sorry, there was a misunderstanding, my replies were for chandu004 and his fprintf approach.
Anyway, I dont know why ODBC behave that way. But why don't you use COM ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
i know chadu,s approch was not correct. actually i am not much more comfertable with COM
so i had tried to do it throgh odbc.
thank u
|
|
|
|
|
Well I think CP article search engine may help you [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|