Click here to Skip to main content
15,851,510 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: trying to understand DLL and Thread local storage Pin
ForNow5-Dec-22 8:37
ForNow5-Dec-22 8:37 
GeneralRe: trying to understand DLL and Thread local storage Pin
jschell12-Dec-22 11:21
jschell12-Dec-22 11:21 
NewsGood news, /clr builds will soon add C++ 20 support! Pin
John Schroedl15-Nov-22 6:49
professionalJohn Schroedl15-Nov-22 6:49 
Questionrekursif Pin
Achmad Roihan28-Oct-22 3:31
Achmad Roihan28-Oct-22 3:31 
AnswerRe: rekursif Pin
OriginalGriff28-Oct-22 3:38
mveOriginalGriff28-Oct-22 3:38 
Questionrekursif program (Recursive Program) Pin
Achmad Roihan26-Oct-22 20:51
Achmad Roihan26-Oct-22 20:51 
AnswerRe: rekursif program (Recursive Program) Pin
OriginalGriff26-Oct-22 21:02
mveOriginalGriff26-Oct-22 21:02 
QuestionHow to close & clear the oledbconnection on form2()_load? Pin
Paramu19739-Oct-22 15:10
Paramu19739-Oct-22 15:10 
Hi,
I am using vs-2015. Managed C++/Cli Windows Forms Applications. I have Form1-MdiContainer & Form2. From Form1_Button_Click() accessing Form2.
In Form2_Load() I have OLEDBConnection. For When I press Form1-Button_Click(),
First time it's working good. Also when I re-click() the same Form1-Button()
the whole application is getting closed. I analysed that when I close the OLEDBConnection, the whole program is also getting closed. And the same code working good in c#. I can't understand my mistakes..! Thanks.

Note:- For First time when I click the Form1-Button no problem it's working good. But for re-click() whole application is getting closed().
Thanks Again

My Codes
Form1-MdiContainer()
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    Form2^ MyStForm = Form2::GetForm(true, this);
    MyStForm->MdiParent = this;
    MyStForm->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
    MyStForm->Dock = DockStyle::Fill;
    MyStForm->Show();
}
Form2-Top side
    public ref class Form2 : public System::Windows::Forms::Form
    {
        public: static Form2^ Form2::_instance = nullptr;
        public: static Form2^ Form2::GetForm(bool IsMDIChild, System::Windows::Forms::Form^ MyInstFrm) {
            if (_instance == nullptr)
                _instance = gcnew Form2();
            if (_instance->IsDisposed)
                _instance = gcnew Form2();
            if (IsMDIChild)
                _instance->MdiParent = MyInstFrm;
            return _instance;
        }
        blah..blah...blah...
         }

Form2-Load()
private: System::Void Form2_Load(System::Object^  sender, System::EventArgs^  e) {
    String^ MyStrConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + MyExcelFile + "; Extended Properties=\"Excel 12.0; HDR=YES; OLE DB Services=-1; \"";
    String^ MyExcelFile="C:\Students\Names.xlsx";
    String^ MyExcelSheet = "[Sheet1$]";
    String^ MySQLSelect = "select * from " + MyExcelSheet;
    System::Data::OleDb::OleDbConnection^ Cn1 = nullptr;
    Cn1 = gcnew System::Data::OleDb::OleDbConnection();
    Cn1->ConnectionString = MyStrConn;
    System::Data::OleDb::OleDbCommand^ MyCmd = nullptr;
    MyCmd = gcnew System::Data::OleDb::OleDbCommand();
    MyCmd->CommandText = MySQLSelect;
    MyCmd->Connection = Cn1;
    Cn1->Open();
        System::Data::OleDb::OleDbDataAdapter^ Da1 = gcnew System::Data::OleDb::OleDbDataAdapter(MyCmd);
        Da1->Fill(MyDataTable);
    Cn1->Close(); //????????????????? getting stuck
    if (Cn1 != nullptr){
        MyCmd->Cancel();
    }
    //Cn1->ConnectionString = nullptr;
    //Cn1->ReleaseObjectPool();
    MyCmd = nullptr;
    Cn1 = nullptr;

} 
Thanks
AnswerRe: How to close & clear the oledbconnection on form2()_load? Pin
Gerry Schmitz9-Oct-22 20:32
mveGerry Schmitz9-Oct-22 20:32 
QuestionHow does the compiler achieve the CRT remapping? Pin
John Schroedl22-Aug-22 11:50
professionalJohn Schroedl22-Aug-22 11:50 
Question[Solved] I hope there is a Managed C++/CLR person left to help me with Parallel::For Pin
madusmacus27-Jul-22 5:25
madusmacus27-Jul-22 5:25 
AnswerRe: I hope there is a Managed C++/CLR person left to help me with Parallel::For Pin
Richard Deeming27-Jul-22 23:13
mveRichard Deeming27-Jul-22 23:13 
General[Final Code Here] Re: I hope there is a Managed C++/CLR person left to help me with Parallel::For Pin
madusmacus27-Jul-22 23:35
madusmacus27-Jul-22 23:35 
Questionc++ forms 2022 code Pin
Member 884846417-Jun-22 2:37
Member 884846417-Jun-22 2:37 
AnswerRe: c++ forms 2022 code Pin
Richard MacCutchan17-Jun-22 4:56
mveRichard MacCutchan17-Jun-22 4:56 
QuestionI want to write a C++/CLI wrapper class library which can be utilized in both C++ and C# applications. Pin
Member 121624009-Jun-22 22:45
Member 121624009-Jun-22 22:45 
Questionsimplifying code Pin
hshan_15-Mar-22 7:30
hshan_15-Mar-22 7:30 
AnswerRe: simplifying code Pin
Victor Nijegorodov15-Mar-22 10:22
Victor Nijegorodov15-Mar-22 10:22 
GeneralRe: simplifying code Pin
Ghazi Warrior22-Mar-22 20:46
Ghazi Warrior22-Mar-22 20:46 
GeneralRe: simplifying code Pin
hshan_19-Apr-22 4:35
hshan_19-Apr-22 4:35 
AnswerRe: simplifying code Pin
Craig Robbins15-Mar-22 10:25
Craig Robbins15-Mar-22 10:25 
QuestionConvert From C# To Visual C++ 2015 Pin
Paramu197313-Dec-21 21:21
Paramu197313-Dec-21 21:21 
Rant[REPOST] Convert From C# To Visual C++ 2015 Pin
Richard Deeming13-Dec-21 22:56
mveRichard Deeming13-Dec-21 22:56 
GeneralRe: [REPOST] Convert From C# To Visual C++ 2015 Pin
Paramu197316-Dec-21 22:14
Paramu197316-Dec-21 22:14 
AnswerRe: Convert From C# To Visual C++ 2015 Pin
Richard MacCutchan13-Dec-21 22:58
mveRichard MacCutchan13-Dec-21 22:58 

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.