Click here to Skip to main content
15,889,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CString to const *char or clr Pin
Christian Graus20-May-07 18:37
protectorChristian Graus20-May-07 18:37 
AnswerRe: CString to const *char or clr Pin
Manoj Kumar Rai20-May-07 20:17
professionalManoj Kumar Rai20-May-07 20:17 
AnswerRe: CString to const *char or clr Pin
prasad_som20-May-07 20:23
prasad_som20-May-07 20:23 
AnswerRe: CString to const *char or clr Pin
prasad_som20-May-07 20:20
prasad_som20-May-07 20:20 
QuestionCustom Caption in XP Pin
maxus9920-May-07 15:53
maxus9920-May-07 15:53 
AnswerRe: Custom Caption in XP Pin
Hamid_RT20-May-07 18:48
Hamid_RT20-May-07 18:48 
GeneralRe: Custom Caption in XP Pin
maxus9921-May-07 3:19
maxus9921-May-07 3:19 
QuestionSQL transaction rollback problem Pin
Moonis Ahmed20-May-07 15:12
Moonis Ahmed20-May-07 15:12 
hi,i am new to visual C++ programming. i have a simple visual C++ program that involves basic sql transactions and if a query fails then i have tried to rollback all the previous transactions as well. I am using MS SQL Server. the problem is that the rollback is not working in the tables in the server while when i run the program in the debug mode it shows that the rollback feature is working as it returns a positive integer from the rollback() function. the program shows no errors or warnings.

Can anyone provide some suggestions? For testing i have used three queries in which the third one has been intentionally left wrong. I need the first two queries to be rollbacked when the error occurs in the third query.

Would be glad if you can point out other errors as i am still learning C++ programming...

Attached is the code:
<br />
class test<br />
{<br />
   <br />
    public:<br />
        void testmethod()<br />
        {           CDatabase dbobject[100];<br />
                static int counter=0;<br />
                char query [3][100]={{"Insert into product values (1,'keyboard')"},{"Insert into product values (2,'mouse')"},{"Insert into product values (2,'cable')"}};<br />
                try<br />
                        {<br />
                            for(int i=0;i<(sizeof(dbobject)/sizeof(dbobject[0]));i++)<br />
                            {<br />
                                dbobjectIdea.OpenEx(_T( "DSN=mytest" ),CDatabase::noOdbcDialog );<br />
                                dbobjectIdea.BeginTrans();<br />
                                dbobjectIdea.ExecuteSQL(queryIdea);<br />
                                dbobjectIdea.CommitTrans();<br />
                                cout<<"Query Execution Successful\n";<br />
                                counter++;<br />
                                dbobjectIdea.Close();<br />
                            }<br />
                        }<br />
                catch (CDBException *pEx)<br />
                        {<br />
                            pEx->ReportError();<br />
                            dbobject[counter].Close();<br />
                            for(int j=counter-1;j>=0;j--)<br />
                            {    dbobject[j].OpenEx(_T( "DSN=mytest" ),CDatabase::noOdbcDialog );<br />
                                dbobject[j].BeginTrans();<br />
                                int c = dbobject[j].Rollback();<br />
                                dbobject[j].Close();<br />
                                cout<<"SQL Query Rollbacked!\n";<br />
                            }<br />
                        }<br />
        }<br />
};<br />
void main()<br />
{<br />
    test t;<br />
    t.testmethod();<br />
}

AnswerRe: SQL transaction rollback problem Pin
zhang80060520-May-07 19:37
zhang80060520-May-07 19:37 
GeneralRe: SQL transaction rollback problem Pin
Moonis Ahmed20-May-07 19:50
Moonis Ahmed20-May-07 19:50 
GeneralRe: SQL transaction rollback problem Pin
Moonis Ahmed22-May-07 22:55
Moonis Ahmed22-May-07 22:55 
Questiondirect3d in layered wnd Pin
johny_d20-May-07 10:26
johny_d20-May-07 10:26 
QuestionHow to get hWnd in MFC? Pin
bankai12320-May-07 7:40
bankai12320-May-07 7:40 
AnswerRe: How to get hWnd in MFC? Pin
Hamid_RT20-May-07 7:57
Hamid_RT20-May-07 7:57 
AnswerRe: How to get hWnd in MFC? Pin
prasad_som20-May-07 20:16
prasad_som20-May-07 20:16 
QuestionPolygons / PtInRegion Pin
m.dietz20-May-07 6:49
m.dietz20-May-07 6:49 
Question_CrtSetBreakAlloc does nothing! Pin
dum20-May-07 6:37
dum20-May-07 6:37 
AnswerRe: _CrtSetBreakAlloc does nothing! Pin
Mark Salsbery20-May-07 7:09
Mark Salsbery20-May-07 7:09 
GeneralRe: _CrtSetBreakAlloc does nothing! Pin
dum20-May-07 8:50
dum20-May-07 8:50 
GeneralRe: _CrtSetBreakAlloc does nothing! Pin
Mark Salsbery20-May-07 9:04
Mark Salsbery20-May-07 9:04 
QuestionRe: _CrtSetBreakAlloc does nothing! Pin
dum20-May-07 9:47
dum20-May-07 9:47 
AnswerRe: _CrtSetBreakAlloc does nothing! Pin
Mark Salsbery20-May-07 11:00
Mark Salsbery20-May-07 11:00 
GeneralRe: _CrtSetBreakAlloc does nothing! Pin
dum20-May-07 14:08
dum20-May-07 14:08 
GeneralRe: _CrtSetBreakAlloc does nothing! Pin
Nibu babu thomas20-May-07 19:19
Nibu babu thomas20-May-07 19:19 
AnswerRe: _CrtSetBreakAlloc does nothing! Pin
Gary R. Wheeler20-May-07 14:04
Gary R. Wheeler20-May-07 14:04 

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.