From: Janusz M <januszms.usunto.@usunto.interia.pl> - 2004-01-18 16:18:42
|
Hi, First thanks for a good job. Second a little problem. I am using Visual C++ Standard 2003,NET 1.1,Managed C++,Windows XP Home,Firebird 1.5 RC8. When I try to open the TableMappings collections editor in the FbDataAdapter I get such a message "Unable to retrieve the schema from the database table.Source column mapping information will not be avaible. Would you like to continue.". After clicking the Yes button I get the error message "Specified cast is invalid". So I always have to write myself the code for the table mapinngs and column mappings thanks for any help, Janusz Mars |
From:
<car...@te...> - 2004-01-18 20:37:07
|
Hello: > First thanks for a good job. Tanks :) > So I always have to write myself the code for the table mapinngs and column > mappings Can you send a test case ?? -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Janusz M <januszms.usunto.@usunto.interia.pl> - 2004-01-18 23:16:15
|
Hi, My test case Firebird 1.5RC8. FirebirdNETProvider1.5 RC2 Database test.fdb, /*************************************************************************** ***/ /**** Generated by IBExpert 2003.12.18 2004-01-19 00:05:32 ****/ /*************************************************************************** ***/ SET SQL DIALECT 3; SET NAMES WIN1250; CREATE DATABASE 'd:\test.fdb' USER 'SYSDBA' PASSWORD 'masterkey' PAGE_SIZE 1024 DEFAULT CHARACTER SET WIN1250; /*************************************************************************** ***/ /**** Tables ****/ /*************************************************************************** ***/ CREATE TABLE TABLE_TEST ( FIELD1 INTEGER NOT NULL, FIELD2 CHAR(10) ); /*************************************************************************** ***/ /**** Primary Keys ****/ /*************************************************************************** ***/ ALTER TABLE TABLE_TEST ADD CONSTRAINT PK_TABLE_TEST PRIMARY KEY (FIELD1); The simple form whitout any controls except FbConnection,FbCommand,FbDataAdpter,FbCommandBuilder. The code generated from Visual C++ Standard 2003 : #pragma once namespace fbTest { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace FirebirdSql::Data::Firebird; /// <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 __gc class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } protected: void Dispose(Boolean disposing) { if (disposing && components) { components->Dispose(); } __super::Dispose(disposing); } private: FirebirdSql::Data::Firebird::FbConnection * fbConnection1; private: FirebirdSql::Data::Firebird::FbCommand * fbCommand1; private: FirebirdSql::Data::Firebird::FbCommandBuilder * fbCommandBuilder1; private: FirebirdSql::Data::Firebird::FbDataAdapter * fbDataAdapter1; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container * components; /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->fbConnection1 = new FirebirdSql::Data::Firebird::FbConnection(); this->fbCommand1 = new FirebirdSql::Data::Firebird::FbCommand(); this->fbCommandBuilder1 = new FirebirdSql::Data::Firebird::FbCommandBuilder(); this->fbDataAdapter1 = new FirebirdSql::Data::Firebird::FbDataAdapter(); // // fbConnection1 // this->fbConnection1->ConnectionString = S"User=SYSDBA;Password=masterkey;Database=d:\\test.fdb;DataSource=localhost; Port=305" S"0;Dialect=3;Charset=WIN1250;Role=;Connection lifetime=0;Connection timeout=15;Po" S"oling=False;Packet Size=8192"; // // fbCommand1 // this->fbCommand1->CommandText = S"select field1,field2 from table_test"; this->fbCommand1->Connection = this->fbConnection1; // // fbCommandBuilder1 // this->fbCommandBuilder1->DataAdapter = this->fbDataAdapter1; // // fbDataAdapter1 // this->fbDataAdapter1->SelectCommand = this->fbCommand1; System::Data::Common::DataTableMapping* __mcTemp__1[] = new System::Data::Common::DataTableMapping*[1]; __mcTemp__1[0] = new System::Data::Common::DataTableMapping(S"Table", S"Table", new System::Data::Common::DataColumnMapping * [0]); this->fbDataAdapter1->TableMappings->AddRange(__mcTemp__1); // // Form1 // this->AutoScaleBaseSize = System::Drawing::Size(5, 13); this->ClientSize = System::Drawing::Size(552, 254); this->Name = S"Form1"; this->Text = S"Form1"; } }; } regards Janusz Mars |
From:
<car...@te...> - 2004-01-19 12:56:12
|
Hello: > My test case I will try to take a look at it soon, thanks -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Janusz M <januszms.usunto.@usunto.interia.pl> - 2004-01-19 22:21:53
|
Hi, I have added to this form I have send to you a textbox control and a button control. I have bound the textbox to the datasource and to the field Field1. On button click I update the datatable. The code is private: System::Void button1_Click(System::Object * sender, System::EventArgs * e) { try { dataSet1->Tables->Item[S"table_test"]->Rows->Item[0]->EndEdit() ; fbDataAdapter1->Update(dataSet1->Tables->Item[S"table_test"]); }catch(Exception * e ){ MessageBox::Show(e->Message); } } All works OK but when I have filled the textbox with the invalid characters, for example instead of a number ( field Field1 is integer ) I have written non number string 'abc', after call fbDataAdapter1->Update the programm hangs. Should it be exception "Invalid format ...". Sorry for my english. regards, Janusz Uzytkownik "Carlos Guzmán Álvarez" <car...@te...> napisal w wiadomosci news:400...@te...... > Hello: > > > My test case > > I will try to take a look at it soon, thanks > > > > > -- > Best regards > > Carlos Guzmán Álvarez > Vigo-Spain > > > ------------------------------------------------------- > The SF.Net email is sponsored by EclipseCon 2004 > Premiere Conference on Open Tools Development and Integration > See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. > http://www.eclipsecon.org/osdn > _______________________________________________ > Firebird-net-provider mailing list > Fir...@li... > https://lists.sourceforge.net/lists/listinfo/firebird-net-provider > |
From:
<car...@te...> - 2004-01-20 10:51:49
|
Hello: > All works OK but when I have filled the textbox with the invalid characters, > for example instead of a number > ( field Field1 is integer ) I have written non number string 'abc', after > call fbDataAdapter1->Update > the programm hangs. Should it be exception "Invalid format ...". I can't reproduce this, can you send a test case ?? please. -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Janusz M <januszms.usunto.@usunto.interia.pl> - 2004-01-21 20:00:23
|
Hi, I am sending you a simple test case. Database is the same as in my previous test case. CREATE TABLE TABLE_TEST ( FIELD1 INTEGER NOT NULL, FIELD2 CHAR(10) ); ALTER TABLE TABLE_TEST ADD CONSTRAINT PK_TABLE_TEST PRIMARY KEY (FIELD1); First you must insert a one record in the tabe_test insert into table_test (field1,field2) values (1,'a'); Then run this form below, type the character '2' in the textbox labelled Field1 and press the button "Update". The program works OK. Try to type the character 'x' in the textbox labelled Field1 (notice that the Field1 is an integer type) and press the button "Update". The program hangs Try to type the string '12345678901' in the textbox labelled Field2 (notice that the Field2 is char(10) ) and press the button "Update". The program hangs too. This is the test form: #pragma once namespace fbTest { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace FirebirdSql::Data::Firebird; /// <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 __gc class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } protected: void Dispose(Boolean disposing) { if (disposing && components) { components->Dispose(); } __super::Dispose(disposing); } private: FirebirdSql::Data::Firebird::FbConnection * fbConnection1; private: FirebirdSql::Data::Firebird::FbCommand * fbCommand1; private: FirebirdSql::Data::Firebird::FbCommandBuilder * fbCommandBuilder1; private: FirebirdSql::Data::Firebird::FbDataAdapter * fbDataAdapter1; private: System::Data::DataSet * dataSet1; private: System::Data::DataTable * dataTable1; private: System::Data::DataColumn * dataColumn1; private: System::Data::DataColumn * dataColumn2; private: System::Windows::Forms::Button * button1; private: System::Windows::Forms::TextBox * textBox1; private: System::Windows::Forms::TextBox * textBox2; private: System::Windows::Forms::Label * label1; private: System::Windows::Forms::Label * label2; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container * components; /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { System::Configuration::AppSettingsReader * configurationAppSettings = new System::Configuration::AppSettingsReader(); this->fbConnection1 = new FirebirdSql::Data::Firebird::FbConnection(); this->fbCommand1 = new FirebirdSql::Data::Firebird::FbCommand(); this->fbCommandBuilder1 = new FirebirdSql::Data::Firebird::FbCommandBuilder(); this->fbDataAdapter1 = new FirebirdSql::Data::Firebird::FbDataAdapter(); this->dataTable1 = new System::Data::DataTable(); this->dataColumn1 = new System::Data::DataColumn(); this->dataColumn2 = new System::Data::DataColumn(); this->dataSet1 = new System::Data::DataSet(); this->button1 = new System::Windows::Forms::Button(); this->textBox1 = new System::Windows::Forms::TextBox(); this->textBox2 = new System::Windows::Forms::TextBox(); this->label1 = new System::Windows::Forms::Label(); this->label2 = new System::Windows::Forms::Label(); (__try_cast<System::ComponentModel::ISupportInitialize * >(this->dataTable1))->BeginInit(); (__try_cast<System::ComponentModel::ISupportInitialize * >(this->dataSet1))->BeginInit(); this->SuspendLayout(); // // fbConnection1 // this->fbConnection1->ConnectionString = (__try_cast<System::String * >(configurationAppSettings->GetValue(S"User=SYSDBA;Password=masterkey;Databa se=d:\\test.fdb;DataSource=localhost;Port=305" S"0;Dialect=3;Charset=WIN1250;Role=;Connection lifetime=0;Connection timeout=15;Po" S"oling=False;Packet Size=8192", __typeof(System::String)))); // // fbCommand1 // this->fbCommand1->CommandText = S"select field1,field2 from table_test"; this->fbCommand1->Connection = this->fbConnection1; // // fbCommandBuilder1 // this->fbCommandBuilder1->DataAdapter = this->fbDataAdapter1; // // fbDataAdapter1 // this->fbDataAdapter1->SelectCommand = this->fbCommand1; System::Data::Common::DataTableMapping* __mcTemp__1[] = new System::Data::Common::DataTableMapping*[1]; __mcTemp__1[0] = new System::Data::Common::DataTableMapping(S"Table", S"Table", new System::Data::Common::DataColumnMapping * [0]); this->fbDataAdapter1->TableMappings->AddRange(__mcTemp__1); // // dataTable1 // System::Data::DataColumn* __mcTemp__2[] = new System::Data::DataColumn*[2]; __mcTemp__2[0] = this->dataColumn1; __mcTemp__2[1] = this->dataColumn2; this->dataTable1->Columns->AddRange(__mcTemp__2); System::Data::Constraint* __mcTemp__3[] = new System::Data::Constraint*[1]; System::String* __mcTemp__4[] = new System::String*[1]; __mcTemp__4[0] = S"Field1"; __mcTemp__3[0] = new System::Data::UniqueConstraint(S"Constraint1", __mcTemp__4, true); this->dataTable1->Constraints->AddRange(__mcTemp__3); System::Data::DataColumn* __mcTemp__5[] = new System::Data::DataColumn*[1]; __mcTemp__5[0] = this->dataColumn1; this->dataTable1->PrimaryKey = __mcTemp__5; this->dataTable1->TableName = S"table_test"; // // dataColumn1 // this->dataColumn1->AllowDBNull = false; this->dataColumn1->Caption = S"Kolumna 1"; this->dataColumn1->ColumnName = S"Field1"; // // dataColumn2 // this->dataColumn2->Caption = S"Kolumna 2"; this->dataColumn2->ColumnName = S"Field2"; // // dataSet1 // this->dataSet1->DataSetName = S"NewDataSet"; this->dataSet1->Locale = new System::Globalization::CultureInfo(S"pl-PL"); System::Data::DataTable* __mcTemp__6[] = new System::Data::DataTable*[1]; __mcTemp__6[0] = this->dataTable1; this->dataSet1->Tables->AddRange(__mcTemp__6); // // button1 // this->button1->Location = System::Drawing::Point(240, 120); this->button1->Name = S"button1"; this->button1->Size = System::Drawing::Size(72, 32); this->button1->TabIndex = 1; this->button1->Text = S"Update"; this->button1->Click += new System::EventHandler(this, button1_Click); // // textBox1 // this->textBox1->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", this->dataSet1, S"table_test.Field1")); this->textBox1->Location = System::Drawing::Point(80, 32); this->textBox1->Name = S"textBox1"; this->textBox1->Size = System::Drawing::Size(120, 20); this->textBox1->TabIndex = 2; this->textBox1->Text = S"textBox1"; // // textBox2 // this->textBox2->DataBindings->Add(new System::Windows::Forms::Binding(S"Text", this->dataSet1, S"table_test.Field2")); this->textBox2->Location = System::Drawing::Point(80, 80); this->textBox2->Name = S"textBox2"; this->textBox2->Size = System::Drawing::Size(120, 20); this->textBox2->TabIndex = 2; this->textBox2->Text = S"textBox1"; // // label1 // this->label1->Location = System::Drawing::Point(32, 32); this->label1->Name = S"label1"; this->label1->Size = System::Drawing::Size(40, 23); this->label1->TabIndex = 3; this->label1->Text = S"Field1"; // // label2 // this->label2->Location = System::Drawing::Point(32, 80); this->label2->Name = S"label2"; this->label2->Size = System::Drawing::Size(40, 23); this->label2->TabIndex = 3; this->label2->Text = S"Field2"; // // Form1 // this->AutoScaleBaseSize = System::Drawing::Size(5, 13); this->ClientSize = System::Drawing::Size(336, 174); this->Controls->Add(this->label1); this->Controls->Add(this->textBox1); this->Controls->Add(this->button1); this->Controls->Add(this->textBox2); this->Controls->Add(this->label2); this->Name = S"Form1"; this->Text = S"Form1"; this->Load += new System::EventHandler(this, Form1_Load); (__try_cast<System::ComponentModel::ISupportInitialize * >(this->dataTable1))->EndInit(); (__try_cast<System::ComponentModel::ISupportInitialize * >(this->dataSet1))->EndInit(); this->ResumeLayout(false); } private: System::Void Form1_Load(System::Object * sender, System::EventArgs * e) { fbDataAdapter1->Fill(dataSet1,S"table_test"); } private: System::Void button1_Click(System::Object * sender, System::EventArgs * e) { try { dataSet1->Tables->Item[S"table_test"]->Rows->Item[0]->EndEdit() ; fbDataAdapter1->Update(dataSet1->Tables->Item[S"table_test"]); } catch(Exception * e ){ MessageBox::Show(e->Message); } } }; } Best regards, Janusz Mars |