Icon View Incident Report

Serious Serious
Reported By: Robin Joseph
Reported On: 4/9/2008
For: Version 1.09 Build 1
# 2599 Using EDBDataAdapter Update Method With INSERT Statement Causes NullReference Exception

Using VS200, EDB 1.9.1 .Net

I am trying to insert into a table using the EDBDataAdapter using the following code. I suspect that the problem is probably my understanding of C# and ADO.net but I would appreciate your help. The Update line gives an NullReference Exception.

DataTable dataTable = new DataTable();

dataTable.Columns.Add("Col1", typeof(System.Int32));
dataTable.Columns.Add("Col2", typeof(System.Int32));

DataRow row = dataTable.NewRow();
row["Col1"] = 11;
row["Col2"] = 22;
dataTable.Rows.Add(row);

row = dataTable.NewRow();
row["Col1"] = 33;
row["Col2"] = 44;
dataTable.Rows.Add(row);

EDBCommand DataCommand = new EDBCommand("INSERT INTO
TestTable (Col1, Col2) VALUES(:Col1,:Col2)");

DataCommand.Parameters[0].DbType = DbType.Int32;
DataCommand.Parameters[0].SourceColumn = "Col1";
DataCommand.Parameters[1].DbType = DbType.Int32;
DataCommand.Parameters[1].SourceColumn = "Col2";

EDBDataAdapter DataAdapter = new EDBDataAdapter();
DataAdapter.InsertCommand = DataCommand;
DataAdapter.InsertCommand.Connection = new
EDBConnection(EDBConnStr);
DataAdapter.InsertCommand.Connection.Open();

DataCommand.Prepare();
DataAdapter.Update(dataTable);



Comments Comments
The problem was that the base .Net code was asking for a result set column count, and the .Net data provider was not expecting such a request for an INSERT statement.


Resolution Resolution
Fixed Problem on 4/12/2008 in version 1.09 build 2


Products Affected Products Affected
ElevateDB DAC Client-Server
ElevateDB DAC Client-Server with Source
ElevateDB DAC Standard
ElevateDB DAC Standard with Source
ElevateDB DAC Trial

Image