DataTable Source and Name property question
DataTable Source and Name property question
I have a simply DataTable that was generated with DevArt wizard. Then i changed the Name property on the DataTable, but maintain the Source value.
Using the following code
....
OracleDataAdapter adapter = new OracleDataAdapter();
OracleCommandBuilder comdBuilder = new OracleCommandBuilder(adapter);
adapter.SelectCommand = mails.SelectCommand;
adapter.Update(mails);
....
where mails is the DataTable that i mentioned above. The error i get say "Missing DataColumn 'ID_MAIL' in DataTable 'Mail' for Source Column 'ID_MAIL'. This error is because i changed the name of the column ID_MAIL to IdMail. If i change it back, everything works fine.
My question is, if it is possible to change the Name property. This would be great, because, it allows me to make the code more readable.
Thanks
Using the following code
....
OracleDataAdapter adapter = new OracleDataAdapter();
OracleCommandBuilder comdBuilder = new OracleCommandBuilder(adapter);
adapter.SelectCommand = mails.SelectCommand;
adapter.Update(mails);
....
where mails is the DataTable that i mentioned above. The error i get say "Missing DataColumn 'ID_MAIL' in DataTable 'Mail' for Source Column 'ID_MAIL'. This error is because i changed the name of the column ID_MAIL to IdMail. If i change it back, everything works fine.
My question is, if it is possible to change the Name property. This would be great, because, it allows me to make the code more readable.
Thanks
Column mappings in DataSet can be set on the 4th step of Devart DataSet Wizard. Please tell us the steps we should follow to reproduce the problem. Also specify the version (x.xx.xxx) of your dotConnect for Oracle. You can find it in the Tools > Oracle > About menu of Visual Studio.
The version i am using is 5.20.33.
As an example.
Suppose you have a table A with 2 columns COLUMN_A and COLUMNB.
The first one has an underscore and the second one doesn't.
When using the DataSet wizard, i want to name the columns, ColumnA and ColumnB, so that the datatable has the properties with those names.
After i generate the datatable i run some test. When i add a row, the insert command generated is wrong, and for ColumnA, it always send a null value.
I i rename the property Column_A, it works fine
As an example.
Suppose you have a table A with 2 columns COLUMN_A and COLUMNB.
The first one has an underscore and the second one doesn't.
When using the DataSet wizard, i want to name the columns, ColumnA and ColumnB, so that the datatable has the properties with those names.
After i generate the datatable i run some test. When i add a row, the insert command generated is wrong, and for ColumnA, it always send a null value.
I i rename the property Column_A, it works fine
I have found a temporary solution. After generating the datatable, i have to manually update the Insert/Update parameter collection, so that the parameter that corresponds to the ColoumnA, must have the SourceColumn property set to ColumnA (the oroginal value is COLUMN_A). This is why it always set null, because i does not match the command with the datatable column name.
I still cannot reproduce the issue. Here are the steps I have followed (with Visual Studio 2008):
1) installed dotConnect for Oracle v 5.20.33 Professional;
2) executed this script in my Oracle Server 11R2 database:
3) ran DataSet Wizard (Tools > Oracle > DataSet Wizard) in my project and changed DataSet Column COLUMN_A --> COLUMNA on the 4th step;
4) executed the following code successfully (row was inserted into table in the database):
The row object contains 2 properties: COLUMNA and COLUMNB. The COLUMN_A parameter of insert command's parameters collection of my ABTableAdapter contains SourceColumn=COLUMN_A.
Please tell us what should be changed in the above steps to reproduce the problem with the NULL value. You have found out that COLUMN_A parameter's value is NULL from dbMonitor, haven't you?
1) installed dotConnect for Oracle v 5.20.33 Professional;
2) executed this script in my Oracle Server 11R2 database:
Code: Select all
CREATE TABLE AB (
COLUMN_A NUMBER(38),
COLUMNB NUMBER(38));
4) executed the following code successfully (row was inserted into table in the database):
Code: Select all
DataSet1.ABRow row = dataSet11.AB.NewABRow();
row[0] = 1;
row[1] = 1;
dataSet11.AB.AddABRow(row);
dataSet11.Update();
Please tell us what should be changed in the above steps to reproduce the problem with the NULL value. You have found out that COLUMN_A parameter's value is NULL from dbMonitor, haven't you?
I have generated a DataSet with the AB table (left all default names unchanged). Then changed the Name property of the COLUMN_A data column in MS DataSet Designer: COLUMN_A --> COLUMNA. In this case the following code runs successfully with the 5.20.33 version:
Code: Select all
DataSet1 ds = new DataSet1();
ds.Connection = new Devart.Data.Oracle.OracleConnection("server=orcl1120;uid=scott;pwd=tiger;");
DataSet1.ABRow row = ds.AB.NewABRow();
row["COLUMNA"] = 13;
row["COLUMNB"] = 1;
ds.AB.AddABRow(row);
ds.Update();