|
|
|
VC++ работаем с базой
|
|||
|---|---|---|---|
|
#18+
Добрый день, уважаемые, у меня вот какая проблемка, я изучил vс++ (из пакета VS 2005), SQL, только вот у меня проблемка не большая я не догнал как допустим по нажатию на кнопку сделать так чтобы определенному объекту Label1 присвоить значение из определенной ячейки базы((( Ну и соответственно куда потом вписывать запросы чтобы выполнялись, так же по нажатию на кнопки, вообщем нуна ето мне узнать, если кто может подскажите на примере, либо посоветуйте книжку которую мона почитать, желательно с ссылкой на электронную версию, спасибо за помощь. С уважением, Константин. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.10.2007, 13:07:46 |
|
||
|
VC++ работаем с базой
|
|||
|---|---|---|---|
|
#18+
Лонстантин пишет: > как допустим по нажатию на кнопку сделать так чтобы определенному > объекту Label1 присвоить значение из определенной ячейки базы((( Ну и > соответственно куда потом вписывать запросы чтобы выполнялись, так же по Тут же все просто. Надо выполнить запрос получить данные Записать в контрол. Posted via ActualForum NNTP Server 1.4 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.10.2007, 16:10:44 |
|
||
|
VC++ работаем с базой
|
|||
|---|---|---|---|
|
#18+
MasterZiv Лонстантин пишет: > как допустим по нажатию на кнопку сделать так чтобы определенному > объекту Label1 присвоить значение из определенной ячейки базы((( Ну и > соответственно куда потом вписывать запросы чтобы выполнялись, так же по Тут же все просто. Надо выполнить запрос получить данные Записать в контрол. Posted via ActualForum NNTP Server 1.4 Я все это понимаю, SQLом владею, я создаю объект отображения данных из БД gridview все показывает все данные, а вот например чтобы данные из одной ячейки применить скажем для переменной или для Label1, - вот в чем у меня проблема! То есть я могу видеть данные, но вот как с этими данными работать, я не могу понять! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 08.10.2007, 08:16:41 |
|
||
|
VC++ работаем с базой
|
|||
|---|---|---|---|
|
#18+
Лонстантин пишет: > Я все это понимаю, SQLом владею, я создаю объект отображения данных из > БД gridview все показывает все данные, а вот например чтобы данные из > одной ячейки применить скажем для переменной или для Label1, - вот в чем > у меня проблема! Что КОНКРЕТНО ты не можешь понять ? Расскажи нам об этом. Posted via ActualForum NNTP Server 1.4 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 08.10.2007, 09:58:15 |
|
||
|
VC++ работаем с базой
|
|||
|---|---|---|---|
|
#18+
Вот, есть некая база, туда мы посылаем запрос, оттуда возвращается знаечение, оно записывается в dataGridView1, но мне нужно чтобы значение скажем любой ячейки записалось в label1, при нажатии button1, вот и все)) Вот это до меня и не доходит))) #pragma once namespace bd { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for Form1 /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::BindingSource^ bindingSource1; private: bd::DataSet1^ DataSet1; private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::DataGridView^ dataGridView1; private: System::Windows::Forms::BindingSource^ studentBindingSource; private: bd::DataSet1TableAdapters::studentTableAdapter^ studentTableAdapter; private: System::Windows::Forms::DataGridViewTextBoxColumn^ idDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ kotraktDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ passwordDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ fioDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ statusDataGridViewTextBoxColumn; protected: private: System::ComponentModel::IContainer^ components; private: /// <summary> /// Required designer variable. /// </summary> #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->components = (gcnew System::ComponentModel::Container()); this->button1 = (gcnew System::Windows::Forms::Button()); this->label1 = (gcnew System::Windows::Forms::Label()); this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView()); this->idDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->kotraktDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->passwordDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->fioDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->statusDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->studentBindingSource = (gcnew System::Windows::Forms::BindingSource(this->components)); this->bindingSource1 = (gcnew System::Windows::Forms::BindingSource(this->components)); this->DataSet1 = (gcnew bd::DataSet1()); this->studentTableAdapter = (gcnew bd::DataSet1TableAdapters::studentTableAdapter()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->BeginInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->studentBindingSource))->BeginInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->bindingSource1))->BeginInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->DataSet1))->BeginInit(); this->SuspendLayout(); // // button1 // this->button1->Location = System::Drawing::Point(185, 236); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(75, 23); this->button1->TabIndex = 0; this->button1->Text = L"button1"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click); // // label1 // this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(23, 241); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(35, 13); this->label1->TabIndex = 1; this->label1->Text = L"label1"; // // dataGridView1 // this->dataGridView1->AutoGenerateColumns = false; this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(5) {this->idDataGridViewTextBoxColumn, this->kotraktDataGridViewTextBoxColumn, this->passwordDataGridViewTextBoxColumn, this->fioDataGridViewTextBoxColumn, this->statusDataGridViewTextBoxColumn}); this->dataGridView1->DataSource = this->studentBindingSource; this->dataGridView1->Location = System::Drawing::Point(20, 53); this->dataGridView1->Name = L"dataGridView1"; this->dataGridView1->Size = System::Drawing::Size(240, 150); this->dataGridView1->TabIndex = 2; // // idDataGridViewTextBoxColumn // this->idDataGridViewTextBoxColumn->DataPropertyName = L"id"; this->idDataGridViewTextBoxColumn->HeaderText = L"id"; this->idDataGridViewTextBoxColumn->Name = L"idDataGridViewTextBoxColumn"; // // kotraktDataGridViewTextBoxColumn // this->kotraktDataGridViewTextBoxColumn->DataPropertyName = L"kotrakt"; this->kotraktDataGridViewTextBoxColumn->HeaderText = L"kotrakt"; this->kotraktDataGridViewTextBoxColumn->Name = L"kotraktDataGridViewTextBoxColumn"; // // passwordDataGridViewTextBoxColumn // this->passwordDataGridViewTextBoxColumn->DataPropertyName = L"password"; this->passwordDataGridViewTextBoxColumn->HeaderText = L"password"; this->passwordDataGridViewTextBoxColumn->Name = L"passwordDataGridViewTextBoxColumn"; // // fioDataGridViewTextBoxColumn // this->fioDataGridViewTextBoxColumn->DataPropertyName = L"fio"; this->fioDataGridViewTextBoxColumn->HeaderText = L"fio"; this->fioDataGridViewTextBoxColumn->Name = L"fioDataGridViewTextBoxColumn"; // // statusDataGridViewTextBoxColumn // this->statusDataGridViewTextBoxColumn->DataPropertyName = L"status"; this->statusDataGridViewTextBoxColumn->HeaderText = L"status"; this->statusDataGridViewTextBoxColumn->Name = L"statusDataGridViewTextBoxColumn"; // // studentBindingSource // this->studentBindingSource->DataMember = L"student"; this->studentBindingSource->DataSource = this->bindingSource1; // // bindingSource1 // this->bindingSource1->DataSource = this->DataSet1; this->bindingSource1->Position = 0; // // DataSet1 // this->DataSet1->DataSetName = L"DataSet1"; this->DataSet1->SchemaSerializationMode = System::Data::SchemaSerializationMode::IncludeSchema; // // studentTableAdapter // this->studentTableAdapter->ClearBeforeFill = true; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(292, 273); this->Controls->Add(this->dataGridView1); this->Controls->Add(this->label1); this->Controls->Add(this->button1); this->Name = L"Form1"; this->Text = L"Form1"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->EndInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->studentBindingSource))->EndInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->bindingSource1))->EndInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->DataSet1))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { this->label1->Text=""; } private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { // TODO: This line of code loads data into the 'DataSet1.student' table. You can move, or remove it, as needed. this->studentTableAdapter->Fill(this->DataSet1->student); } private: System::Void FillByToolStripButton_Click(System::Object^ sender, System::EventArgs^ e) { try { this->studentTableAdapter->FillBy(this->DataSet1->student); } catch (System::Exception^ ex) { System::Windows::Forms::MessageBox::Show(ex->Message); } } private: System::Void FillBy1ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e) { try { this->studentTableAdapter->FillBy1(this->DataSet1->student); } catch (System::Exception^ ex) { System::Windows::Forms::MessageBox::Show(ex->Message); } } }; } ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 08.10.2007, 13:29:28 |
|
||
|
VC++ работаем с базой
|
|||
|---|---|---|---|
|
#18+
Спасибо за помощь, которой мне не оказали, примного благодарен!!! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.10.2007, 08:20:05 |
|
||
|
VC++ работаем с базой
|
|||
|---|---|---|---|
|
#18+
Тебе надо сперва определиться, какую библиотеку будешь использовать для работы с базой. Чтобы просто исполнять запросы и получать данные можно использовать Борландовские BDE или ADO от MS. Когда ты работаешь с dbGridView он делает работу за тебя, тебе надо только правильно его настроить. Я так понял, задача в работе на более низком уровне. ТОгда используй ADOQuery например. Сможешь писать свои запросы и выполнять их на сервере БД. Если не хочешь работать с борландом - существует много других библиотек. Очень удобная - из QT. Если совсем на низком уровне - можешь помучать Win32 ODBC API. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.10.2007, 10:40:58 |
|
||
|
|

start [/forum/topic.php?fid=57&msg=34851814&tid=2028014]: |
0ms |
get settings: |
8ms |
get forum list: |
13ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
181ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
41ms |
get tp. blocked users: |
1ms |
| others: | 225ms |
| total: | 485ms |

| 0 / 0 |
