Benutzer mit den meisten Antworten
[VS Premium 2010][C++] Fehler beim kompilieren. error LNK2022, error LNK1255

Frage
-
Hallo zusammen,
ich arbeite seit kurzem erst mit Visual Studio und es hat ja nun eine ziemliche Fülle an Funktionen. Diese Menge bricht mir wahrscheinlich gerade als C++-Anfänger das Genick. Ich habe mir ein kleines Programm geschrieben um auf eine Datenbank zuzugreifen und Werte auszulesen und darzustellen. Beim Kompilieren allerdings bekomme ich 100x den Fehler "LNK2022 - Fehler bei Metadatenoperation" und einmal den Fehler "LNK1255 - Fehler bei Verknüpfung aufgrund von Metadatenfehlern." Ich habe mich durch sämtliche Optionen durchgeklickt aber ich finde einfach keine Lösung. Auch diverse Suchmaschinen und andere Foren leiten mich ins nichts. Hier nochmal ein kleiner Auszug:
Fehler 1 error LNK2022: Fehler bei Metadatenoperation (80131195) : Die benutzerdefinierten Attribute sind nicht konsistent: (0x0c000109). [...] MSVCURT.lib(mstartup.obj)
Ich hoffe ihr könnt mir helfen und vielen vielen Dank schonmal vorab für jede erdenkliche Hilfe!
Viele Grüße,
Danny
P.S:
Gibt es hier eine Möglichkeit Dateien anzuhängen? Dann könnte ich meinen Code anfügen und die Suche wär hoffentlich nicht ganz wie die berühmte Suche nach der Nadel im Heuhaufen.- Verschoben Martin RichterModerator Donnerstag, 24. November 2011 10:54 (aus:Visual Studio)
- Verschoben Martin RichterModerator Montag, 2. Januar 2012 09:10 (aus:Visual C++)
Antworten
-
Es ist genauso wie ich vermutet habe: Du verwendest C++/CLI! D.h. der Linker kommt nicht klar weil Du C++/CLI und nativen C++ Code in einer Weise mischt, die nicht OK ist. Frag mich nicht was ihn im Detail stört.
Das ist kein C++ und innerhalb C++/CLI den MySQL Client Code zu verwenden ist auch Eulen nach Athen tragen. Innerhalb von C++/CLI solltest Du natürlich ADO.NET verwenden!
Schmeiß das Projekt weg und fang ein reines Windows, WinAPI oder MFC Project an. Kein managed C++!
Martin Richter -- MVP for VC++ [Germany] -- http://blog.m-ri.de- Als Antwort vorgeschlagen Martin RichterModerator Montag, 2. Januar 2012 09:09
- Als Antwort markiert Robert BreitenhoferModerator Montag, 23. Januar 2012 18:34
Alle Antworten
-
Hallo Martin,
tut mir Leid, dass ich erst jetzt antworte, aber ich war das Wochenende über nicht am Rechner und hatte erst jetzt wieder Zugang zum Code. Ich weiß nicht genau ob ich C++ und C++/CLI durcheinanderbringe. Ich bin was C++ und seine Möglichkeiten angeht noch Neuling und dies ist quasi mein erstes C++-Projekt. Ich habe vorher nur mit Java gearbeitet.
Verwendete Bibliotheken sind
MySQL Connector C++ und
die Boost C++ Library
Hier also der Code. Hoffe er ist für euch einigermaßen übersichtlich und es ist klar was ich möchte.
#pragma once /* Standard C++ Includes */ #include <stdlib.h> #include <iostream> #include <time.h> #include <stdio.h> #include <windows.h> /* MySQL spezifische Includes */ #include "mysql_connection.h" #include <cppconn/driver.h> #include <cppconn/exception.h> #include <cppconn/resultset.h> #include <cppconn/statement.h> #include <cppconn/prepared_statement.h> /* Globale Abbruchvariable */ bool abbruch = false; namespace Systemusage_SQL { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; // Zusammenfassung für Form1 public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); TextBox(); } protected: // Verwendete Ressourcen bereinigen. ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button_connect; private: System::Windows::Forms::Panel^ form_usage; protected: private: System::Windows::Forms::TextBox^ textbox_user; private: System::Windows::Forms::TextBox^ textbox_pass; private: System::Windows::Forms::Label^ label_state; private: System::Windows::Forms::Label^ label_connected; private: System::Windows::Forms::Label^ label_user; protected: private: System::Windows::Forms::Label^ label_pass; private: System::Windows::Forms::Label^ label_mysql; private: System::Windows::Forms::Label^ label_usage; private: System::Windows::Forms::Label^ label_userpwcheck; private: System::Windows::Forms::ComboBox^ combobox_tabelle; private: System::Windows::Forms::Label^ table; private: System::Windows::Forms::Button^ button_curve; private: System::Windows::Forms::ComboBox^ combobox_cpu; private: System::Windows::Forms::Button^ button_cancel; private: Microsoft::VisualBasic::PowerPacks::ShapeContainer^ shapeContainer2; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape1; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape2; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape3; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape4; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape5; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape6; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape7; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape8; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape9; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape10; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape11; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape12; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape13; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape14; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape15; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape16; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape17; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape18; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape19; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape20; private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape21; private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::Label^ label2; private: Microsoft::VisualBasic::PowerPacks::ShapeContainer^ shapeContainer1; private: Microsoft::VisualBasic::PowerPacks::LineShape^ lineShape2; private: Microsoft::VisualBasic::PowerPacks::LineShape^ lineShape1; private: // Erforderliche Designervariable. System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code // Erforderliche Methode für die Designerunterstützung. // Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. void InitializeComponent(void) { this->button_connect = (gcnew System::Windows::Forms::Button()); this->form_usage = (gcnew System::Windows::Forms::Panel()); this->shapeContainer2 = (gcnew Microsoft::VisualBasic::PowerPacks::ShapeContainer()); this->ovalShape14 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape19 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape2 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape3 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape4 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape5 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape6 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape15 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape16 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape20 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape17 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape21 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape18 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape12 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape7 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape11 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape8 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape9 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape13 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape10 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->ovalShape1 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape()); this->textbox_user = (gcnew System::Windows::Forms::TextBox()); this->textbox_pass = (gcnew System::Windows::Forms::TextBox()); this->label_state = (gcnew System::Windows::Forms::Label()); this->label_connected = (gcnew System::Windows::Forms::Label()); this->label_user = (gcnew System::Windows::Forms::Label()); this->label_pass = (gcnew System::Windows::Forms::Label()); this->label_mysql = (gcnew System::Windows::Forms::Label()); this->label_usage = (gcnew System::Windows::Forms::Label()); this->label_userpwcheck = (gcnew System::Windows::Forms::Label()); this->combobox_tabelle = (gcnew System::Windows::Forms::ComboBox()); this->table = (gcnew System::Windows::Forms::Label()); this->button_curve = (gcnew System::Windows::Forms::Button()); this->combobox_cpu = (gcnew System::Windows::Forms::ComboBox()); this->button_cancel = (gcnew System::Windows::Forms::Button()); this->label1 = (gcnew System::Windows::Forms::Label()); this->label2 = (gcnew System::Windows::Forms::Label()); this->shapeContainer1 = (gcnew Microsoft::VisualBasic::PowerPacks::ShapeContainer()); this->lineShape2 = (gcnew Microsoft::VisualBasic::PowerPacks::LineShape()); this->lineShape1 = (gcnew Microsoft::VisualBasic::PowerPacks::LineShape()); this->form_usage->SuspendLayout(); this->SuspendLayout(); // // button_connect // this->button_connect->Location = System::Drawing::Point(50, 233); this->button_connect->Name = L"button_connect"; this->button_connect->Size = System::Drawing::Size(130, 22); this->button_connect->TabIndex = 0; this->button_connect->Text = L"Verbinden"; this->button_connect->UseVisualStyleBackColor = true; this->button_connect->Click += gcnew System::EventHandler(this, &Form1::button_Click); // // form_usage // this->form_usage->BackColor = System::Drawing::SystemColors::ControlDark; this->form_usage->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle; this->form_usage->Controls->Add(this->shapeContainer2); this->form_usage->Location = System::Drawing::Point(261, 89); this->form_usage->Name = L"form_usage"; this->form_usage->Size = System::Drawing::Size(253, 110); this->form_usage->TabIndex = 1; this->form_usage->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::panel1_Paint); // // shapeContainer2 // this->shapeContainer2->Location = System::Drawing::Point(0, 0); this->shapeContainer2->Margin = System::Windows::Forms::Padding(0); this->shapeContainer2->Name = L"shapeContainer2"; this->shapeContainer2->Shapes->AddRange(gcnew cli::array< Microsoft::VisualBasic::PowerPacks::Shape^ >(21) {this->ovalShape14, this->ovalShape19, this->ovalShape2, this->ovalShape3, this->ovalShape4, this->ovalShape5, this->ovalShape6, this->ovalShape15, this->ovalShape16, this->ovalShape20, this->ovalShape17, this->ovalShape21, this->ovalShape18, this->ovalShape12, this->ovalShape7, this->ovalShape11, this->ovalShape8, this->ovalShape9, this->ovalShape13, this->ovalShape10, this->ovalShape1}); this->shapeContainer2->Size = System::Drawing::Size(251, 108); this->shapeContainer2->TabIndex = 0; this->shapeContainer2->TabStop = false; // // ovalShape14 // this->ovalShape14->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape14->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape14->Location = System::Drawing::Point(156, 97); this->ovalShape14->Name = L"ovalShape14"; this->ovalShape14->Size = System::Drawing::Size(10, 10); // // ovalShape19 // this->ovalShape19->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape19->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape19->Location = System::Drawing::Point(216, 97); this->ovalShape19->Name = L"ovalShape19"; this->ovalShape19->Size = System::Drawing::Size(10, 10); // // ovalShape2 // this->ovalShape2->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape2->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape2->Location = System::Drawing::Point(12, 97); this->ovalShape2->Name = L"ovalShape2"; this->ovalShape2->Size = System::Drawing::Size(10, 10); // // ovalShape3 // this->ovalShape3->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape3->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape3->Location = System::Drawing::Point(24, 97); this->ovalShape3->Name = L"ovalShape3"; this->ovalShape3->Size = System::Drawing::Size(10, 10); // // ovalShape4 // this->ovalShape4->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape4->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape4->Location = System::Drawing::Point(36, 97); this->ovalShape4->Name = L"ovalShape4"; this->ovalShape4->Size = System::Drawing::Size(10, 10); // // ovalShape5 // this->ovalShape5->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape5->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape5->Location = System::Drawing::Point(48, 97); this->ovalShape5->Name = L"ovalShape5"; this->ovalShape5->Size = System::Drawing::Size(10, 10); // // ovalShape6 // this->ovalShape6->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape6->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape6->Location = System::Drawing::Point(60, 97); this->ovalShape6->Name = L"ovalShape6"; this->ovalShape6->Size = System::Drawing::Size(10, 10); // // ovalShape15 // this->ovalShape15->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape15->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape15->Location = System::Drawing::Point(168, 97); this->ovalShape15->Name = L"ovalShape15"; this->ovalShape15->Size = System::Drawing::Size(10, 10); // // ovalShape16 // this->ovalShape16->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape16->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape16->Location = System::Drawing::Point(180, 97); this->ovalShape16->Name = L"ovalShape16"; this->ovalShape16->Size = System::Drawing::Size(10, 10); // // ovalShape20 // this->ovalShape20->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape20->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape20->Location = System::Drawing::Point(228, 97); this->ovalShape20->Name = L"ovalShape20"; this->ovalShape20->Size = System::Drawing::Size(10, 10); // // ovalShape17 // this->ovalShape17->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape17->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape17->Location = System::Drawing::Point(192, 97); this->ovalShape17->Name = L"ovalShape17"; this->ovalShape17->Size = System::Drawing::Size(10, 10); // // ovalShape21 // this->ovalShape21->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape21->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape21->Location = System::Drawing::Point(240, 97); this->ovalShape21->Name = L"ovalShape21"; this->ovalShape21->Size = System::Drawing::Size(10, 10); // // ovalShape18 // this->ovalShape18->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape18->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape18->Location = System::Drawing::Point(204, 97); this->ovalShape18->Name = L"ovalShape18"; this->ovalShape18->Size = System::Drawing::Size(10, 10); // // ovalShape12 // this->ovalShape12->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape12->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape12->Location = System::Drawing::Point(132, 97); this->ovalShape12->Name = L"ovalShape12"; this->ovalShape12->Size = System::Drawing::Size(10, 10); // // ovalShape7 // this->ovalShape7->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape7->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape7->Location = System::Drawing::Point(72, 97); this->ovalShape7->Name = L"ovalShape7"; this->ovalShape7->Size = System::Drawing::Size(10, 10); // // ovalShape11 // this->ovalShape11->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape11->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape11->Location = System::Drawing::Point(120, 97); this->ovalShape11->Name = L"ovalShape11"; this->ovalShape11->Size = System::Drawing::Size(10, 10); // // ovalShape8 // this->ovalShape8->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape8->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape8->Location = System::Drawing::Point(84, 97); this->ovalShape8->Name = L"ovalShape8"; this->ovalShape8->Size = System::Drawing::Size(10, 10); // // ovalShape9 // this->ovalShape9->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape9->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape9->Location = System::Drawing::Point(96, 97); this->ovalShape9->Name = L"ovalShape9"; this->ovalShape9->Size = System::Drawing::Size(10, 10); // // ovalShape13 // this->ovalShape13->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape13->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape13->Location = System::Drawing::Point(144, 97); this->ovalShape13->Name = L"ovalShape13"; this->ovalShape13->Size = System::Drawing::Size(10, 10); // // ovalShape10 // this->ovalShape10->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape10->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape10->Location = System::Drawing::Point(108, 97); this->ovalShape10->Name = L"ovalShape10"; this->ovalShape10->Size = System::Drawing::Size(10, 10); // // ovalShape1 // this->ovalShape1->BackColor = System::Drawing::Color::GreenYellow; this->ovalShape1->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque; this->ovalShape1->Location = System::Drawing::Point(0, 97); this->ovalShape1->Name = L"ovalShape1"; this->ovalShape1->Size = System::Drawing::Size(10, 10); // // textbox_user // this->textbox_user->Location = System::Drawing::Point(50, 89); this->textbox_user->Name = L"textbox_user"; this->textbox_user->Size = System::Drawing::Size(130, 20); this->textbox_user->TabIndex = 5; this->textbox_user->TextChanged += gcnew System::EventHandler(this, &Form1::textbox_user_TextChanged); // // textbox_pass // this->textbox_pass->Location = System::Drawing::Point(50, 141); this->textbox_pass->Name = L"textbox_pass"; this->textbox_pass->PasswordChar = '*'; this->textbox_pass->Size = System::Drawing::Size(130, 20); this->textbox_pass->TabIndex = 6; this->textbox_pass->TextChanged += gcnew System::EventHandler(this, &Form1::textbox_pass_TextChanged); // // label_state // this->label_state->AutoSize = true; this->label_state->Location = System::Drawing::Point(48, 263); this->label_state->Name = L"label_state"; this->label_state->Size = System::Drawing::Size(40, 13); this->label_state->TabIndex = 7; this->label_state->Text = L"Status:"; // // label_connected // this->label_connected->AutoSize = true; this->label_connected->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label_connected->ForeColor = System::Drawing::Color::Red; this->label_connected->Location = System::Drawing::Point(97, 263); this->label_connected->Name = L"label_connected"; this->label_connected->RightToLeft = System::Windows::Forms::RightToLeft::No; this->label_connected->Size = System::Drawing::Size(84, 13); this->label_connected->TabIndex = 8; this->label_connected->Text = L"nicht verbunden"; // // label_user // this->label_user->AutoSize = true; this->label_user->Location = System::Drawing::Point(78, 73); this->label_user->Name = L"label_user"; this->label_user->Size = System::Drawing::Size(75, 13); this->label_user->TabIndex = 9; this->label_user->Text = L"Benutzername"; // // label_pass // this->label_pass->AutoSize = true; this->label_pass->Location = System::Drawing::Point(87, 125); this->label_pass->Name = L"label_pass"; this->label_pass->Size = System::Drawing::Size(50, 13); this->label_pass->TabIndex = 10; this->label_pass->Text = L"Passwort"; // // label_mysql // this->label_mysql->AutoSize = true; this->label_mysql->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label_mysql->Location = System::Drawing::Point(30, 27); this->label_mysql->Name = L"label_mysql"; this->label_mysql->Size = System::Drawing::Size(174, 13); this->label_mysql->TabIndex = 11; this->label_mysql->Text = L"MySQL-Verbindung herstellen"; // // label_usage // this->label_usage->AutoSize = true; this->label_usage->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label_usage->Location = System::Drawing::Point(267, 73); this->label_usage->Name = L"label_usage"; this->label_usage->Size = System::Drawing::Size(84, 13); this->label_usage->TabIndex = 12; this->label_usage->Text = L"CPU Auslastung"; // // label_userpwcheck // this->label_userpwcheck->AutoSize = true; this->label_userpwcheck->ForeColor = System::Drawing::Color::Red; this->label_userpwcheck->Location = System::Drawing::Point(13, 283); this->label_userpwcheck->Name = L"label_userpwcheck"; this->label_userpwcheck->Size = System::Drawing::Size(205, 13); this->label_userpwcheck->TabIndex = 15; this->label_userpwcheck->Text = L"Benutzernamen und Passwort überprüfen!"; this->label_userpwcheck->Visible = false; // // combobox_tabelle // this->combobox_tabelle->FormattingEnabled = true; this->combobox_tabelle->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"VM_E_Testserver_SE", L"HOST_vm17", L"HOST_vm3"}); this->combobox_tabelle->Location = System::Drawing::Point(50, 206); this->combobox_tabelle->Name = L"combobox_tabelle"; this->combobox_tabelle->Size = System::Drawing::Size(130, 21); this->combobox_tabelle->TabIndex = 16; this->combobox_tabelle->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged); // // table // this->table->AutoSize = true; this->table->Location = System::Drawing::Point(87, 188); this->table->Name = L"table"; this->table->Size = System::Drawing::Size(42, 13); this->table->TabIndex = 17; this->table->Text = L"Tabelle"; //
Irgendwie muss ich den Code in Zwei Sätzen posten, sonst wird das ganze nicht angenommen. Ich Entschuldige mich deshalb schonmal für einen Doppelpost:
P.S: Ich würde ja gerne nur das wichtige Filter, da ich allerdings nicht weiß auf welchen Teil des Codes die Fehlermeldung schließt, poste ich den gesamten Code.
|
|
v
Fortsetzung -
// button_curve // this->button_curve->Location = System::Drawing::Point(261, 233); this->button_curve->Name = L"button_curve"; this->button_curve->Size = System::Drawing::Size(130, 25); this->button_curve->TabIndex = 14; this->button_curve->Text = L"CPU Last anzeigen"; this->button_curve->UseVisualStyleBackColor = true; this->button_curve->Visible = false; this->button_curve->Click += gcnew System::EventHandler(this, &Form1::button_Draw); // // combobox_cpu // this->combobox_cpu->FormattingEnabled = true; this->combobox_cpu->Items->AddRange(gcnew cli::array< System::Object^ >(8) {L"Cpu(0)", L"Cpu(1)", L"Cpu(2)", L"Cpu(3)", L"Cpu(4)", L"Cpu(5)", L"Cpu(6)", L"Cpu(7)"}); this->combobox_cpu->Location = System::Drawing::Point(261, 206); this->combobox_cpu->Name = L"combobox_cpu"; this->combobox_cpu->Size = System::Drawing::Size(130, 21); this->combobox_cpu->TabIndex = 18; this->combobox_cpu->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox2_SelectedIndexChanged); // // button_cancel // this->button_cancel->Location = System::Drawing::Point(261, 233); this->button_cancel->Name = L"button_cancel"; this->button_cancel->Size = System::Drawing::Size(130, 26); this->button_cancel->TabIndex = 19; this->button_cancel->Text = L"Abbrechen"; this->button_cancel->UseVisualStyleBackColor = true; this->button_cancel->Visible = false; this->button_cancel->Click += gcnew System::EventHandler(this, &Form1::button_cancel_Click); // // label1 // this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(236, 90); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(25, 13); this->label1->TabIndex = 20; this->label1->Text = L"100"; // // label2 // this->label2->AutoSize = true; this->label2->Location = System::Drawing::Point(244, 185); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(13, 13); this->label2->TabIndex = 21; this->label2->Text = L"0"; // // shapeContainer1 // this->shapeContainer1->Location = System::Drawing::Point(0, 0); this->shapeContainer1->Margin = System::Windows::Forms::Padding(0); this->shapeContainer1->Name = L"shapeContainer1"; this->shapeContainer1->Shapes->AddRange(gcnew cli::array< Microsoft::VisualBasic::PowerPacks::Shape^ >(2) {this->lineShape2, this->lineShape1}); this->shapeContainer1->Size = System::Drawing::Size(553, 307); this->shapeContainer1->TabIndex = 22; this->shapeContainer1->TabStop = false; // // lineShape2 // this->lineShape2->Name = L"lineShape2"; this->lineShape2->X1 = 235; this->lineShape2->X2 = 265; this->lineShape2->Y1 = 89; this->lineShape2->Y2 = 89; // // lineShape1 // this->lineShape1->Name = L"lineShape1"; this->lineShape1->X1 = 237; this->lineShape1->X2 = 265; this->lineShape1->Y1 = 198; this->lineShape1->Y2 = 198; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(553, 307); this->Controls->Add(this->label2); this->Controls->Add(this->label1); this->Controls->Add(this->button_cancel); this->Controls->Add(this->combobox_cpu); this->Controls->Add(this->table); this->Controls->Add(this->combobox_tabelle); this->Controls->Add(this->label_userpwcheck); this->Controls->Add(this->label_connected); this->Controls->Add(this->button_curve); this->Controls->Add(this->label_usage); this->Controls->Add(this->label_mysql); this->Controls->Add(this->label_pass); this->Controls->Add(this->label_user); this->Controls->Add(this->label_state); this->Controls->Add(this->textbox_pass); this->Controls->Add(this->textbox_user); this->Controls->Add(this->form_usage); this->Controls->Add(this->button_connect); this->Controls->Add(this->shapeContainer1); this->Name = L"Form1"; this->Text = L"Systemauslastung"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->form_usage->ResumeLayout(false); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { } private: System::Void panel1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) { } private: System::Void panel2_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) { } private: System::Void panel3_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) { } private: System::Void mysqlconnect() { sql::Driver *driver; sql::Connection *con; sql::Statement *stmt; sql::ResultSet *res; sql::PreparedStatement *pstmt; String^ user; String^ pass; String^ tabelle; user = textbox_user->Text; pass = textbox_pass->Text; /* Verbindung herstellen */ driver = get_driver_instance(); con = driver->connect("*server:port", "username", "password"); /* zur Datenbank verbinden */ con->setSchema("esxtop"); /* Anzeige ob Verbindung erfolgreich hergestellt wurde */ if (con == 0) { label_connected->ForeColor = System::Drawing::Color::Red; label_connected->Text = L"nicht verbunden"; label_userpwcheck->Visible = true; button_curve->Visible = false; } else { label_connected->ForeColor = System::Drawing::Color::Green; label_connected->Text = L"verbunden"; button_curve->Visible = true; } } private: System::Void drawCurve() { sql::ResultSet *res; sql::Statement *stmt; button_curve->Visible = false; button_cancel->Visible = true; int i = 0; int werte[21]; int z = 1; //Hilfsvariable //letzten Wert aus der Tabelle auslesen res = stmt->executeQuery("SELECT id FROM esxtop.HOST_vm17 ORDER BY id DESC"); //damit die letzten 21 Werte erfasst werden i = (int)res - 21; //solange "abbrechen" noch nicht gedrückt wurde die CPU Last anzeigen lassen while (!abbruch) { if (z < 2) { //beim ersten durchlauf, die ersten 21 Werte in das Array eintragen for (int j = 0; j < 21; j++) { res = stmt -> executeQuery("Select Physical Cpu(0)% Util Time FROM esxtop.esxtop.HOST_vm17 WHERE id = 10"); werte[j] = (int)res; i++; } z = 2; } else { // 60 Sekunden Pause, da ein DB-Eintrag nur alle 60 Sekunden erfolgt Sleep(6000); // letzten CPU-Usage Wert auslesen res = stmt -> executeQuery("Select Physical Cpu(0)% Util Time FROM esxtop.esxtop.HOST_vm17 WHERE id = 10"); //Werte durchtauschen und das letzte Element hinten anhängen for (int k = 0; k < 21; k++) { werte[k] = werte[k+1]; } werte[20] = (int)res; } //Punkte neu setzen und die CPU-Usage in der Höhe dazuaddieren ovalShape1->Location = System::Drawing::Point(0, 97 + werte[0]); ovalShape2->Location = System::Drawing::Point(12, 97 + werte[1]); ovalShape3->Location = System::Drawing::Point(24, 97 + werte[2]); ovalShape4->Location = System::Drawing::Point(36, 97 + werte[3]); ovalShape5->Location = System::Drawing::Point(48, 97 + werte[4]); ovalShape6->Location = System::Drawing::Point(60, 97 + werte[5]); ovalShape7->Location = System::Drawing::Point(72, 97 + werte[6]); ovalShape8->Location = System::Drawing::Point(84, 97 + werte[7]); ovalShape9->Location = System::Drawing::Point(96, 97 + werte[8]); ovalShape10->Location = System::Drawing::Point(108, 97 + werte[9]); ovalShape11->Location = System::Drawing::Point(120, 97 + werte[10]); ovalShape12->Location = System::Drawing::Point(132, 97 + werte[11]); ovalShape13->Location = System::Drawing::Point(144, 97 + werte[12]); ovalShape14->Location = System::Drawing::Point(156, 97 + werte[13]); ovalShape15->Location = System::Drawing::Point(168, 97 + werte[14]); ovalShape16->Location = System::Drawing::Point(180, 97 + werte[15]); ovalShape17->Location = System::Drawing::Point(192, 97 + werte[16]); ovalShape18->Location = System::Drawing::Point(204, 97 + werte[17]); ovalShape19->Location = System::Drawing::Point(216, 97 + werte[18]); ovalShape20->Location = System::Drawing::Point(228, 97 + werte[19]); ovalShape21->Location = System::Drawing::Point(240, 97 + werte[20]); //"id"++ i++; } } private: System::Void button_Click(System::Object^ sender, System::EventArgs^ e) { mysqlconnect(); } private: System::Void button_Draw(System::Object^ sender, System::EventArgs^ e) { abbruch = false; drawCurve(); } private: System::Void textbox_pass_TextChanged(System::Object^ sender, System::EventArgs^ e) { } private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { } private: System::Void textbox_user_TextChanged(System::Object^ sender, System::EventArgs^ e) { } private: System::Void comboBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button_cancel_Click(System::Object^ sender, System::EventArgs^ e) { abbruch = true; button_curve->Visible = true; button_cancel->Visible = false; } }; }
Na herzlichen Glückwunsch. Das sprengt natürlich die gesamte Foren-Seite. Gibt es eine Möglichkeit den Code zu spoilern? Das wäre ganz angenehm für die Foren-Betrachtung.
Ich bin dankbar für jede erdenkliche Hilfe!
Viele Grüße,
Danny- Bearbeitet Danny Fonk Dienstag, 29. November 2011 09:58
-
Es ist genauso wie ich vermutet habe: Du verwendest C++/CLI! D.h. der Linker kommt nicht klar weil Du C++/CLI und nativen C++ Code in einer Weise mischt, die nicht OK ist. Frag mich nicht was ihn im Detail stört.
Das ist kein C++ und innerhalb C++/CLI den MySQL Client Code zu verwenden ist auch Eulen nach Athen tragen. Innerhalb von C++/CLI solltest Du natürlich ADO.NET verwenden!
Schmeiß das Projekt weg und fang ein reines Windows, WinAPI oder MFC Project an. Kein managed C++!
Martin Richter -- MVP for VC++ [Germany] -- http://blog.m-ri.de- Als Antwort vorgeschlagen Martin RichterModerator Montag, 2. Januar 2012 09:09
- Als Antwort markiert Robert BreitenhoferModerator Montag, 23. Januar 2012 18:34
-
Das ist alles C++/CLI Code.
Das ist kein normales C++, da Du andere Libraries verwendest die nur auf C++ aufsetzen gehe ich mal davon aus, dass diese eben nicht mit C++/CLI kompatibel sind!
C++/CLI mit Windows Forms macht keinen Sinn...
Martin Richter -- MVP for VC++ [Germany] -- http://blog.m-ri.de