DataAdapter Update() Help

G

Guest

Does anyone know why the DA Update() would throw an exception?

I moved the database but I updated the Conn and the DA, currently
(trying)removing/replacing DS. Is there a another direction I should be
looking in? Does it matter if I move columns in the grid (everything is a
string anyways)? Does the DS need to be udated from the DT?
***************
int rowNo = dg.CurrentRowIndex;

dt = dt .Rows[rowNo].BeginEdit();
dt = dt .Rows[rowNo][columnName] = strgCellFill;
dt = dt .Rows[rowNo].EndEdit();

string s = dt.Rows[rowNo][columnName]; // s = strgCellFill

DataRow dr = dt.Rows[rowNo];
string s1 = dr.RowState.ToString(); // s1 = "Modified"

DS dataSetChanges = getDataSetChanges();

if (dataSetChanges.HasChanges())
{
this.Conn.Open();
this.da.Update(ds); //throws an exception
this.Conn.Close();
}
 
G

Guest

It's a System.Data.OleDb.OleDbException.

Looks like the database. Wouldn't the Open() fail if it was a problem with
the dB?

Should I recreate the Conn, DA and DS

Steve
 
G

Guest

Could it have to do with folder permissions? the properties -security tab
Allow column is checked?? NFTS?? ASPNET permissions?

Steve

Steve B. said:
It's a System.Data.OleDb.OleDbException.

Looks like the database. Wouldn't the Open() fail if it was a problem with
the dB?

Should I recreate the Conn, DA and DS

Steve

Steve B. said:
Does anyone know why the DA Update() would throw an exception?

I moved the database but I updated the Conn and the DA, currently
(trying)removing/replacing DS. Is there a another direction I should be
looking in? Does it matter if I move columns in the grid (everything is a
string anyways)? Does the DS need to be udated from the DT?
***************
int rowNo = dg.CurrentRowIndex;

dt = dt .Rows[rowNo].BeginEdit();
dt = dt .Rows[rowNo][columnName] = strgCellFill;
dt = dt .Rows[rowNo].EndEdit();

string s = dt.Rows[rowNo][columnName]; // s = strgCellFill

DataRow dr = dt.Rows[rowNo];
string s1 = dr.RowState.ToString(); // s1 = "Modified"

DS dataSetChanges = getDataSetChanges();

if (dataSetChanges.HasChanges())
{
this.Conn.Open();
this.da.Update(ds); //throws an exception
this.Conn.Close();
}
 
G

Guest

It's a System.Data.OleDb.OleDbException.

Ok, but you need to catch nd display the complete error of th exception ;)

Bye

-------------------
LEBRUN Thomas
http://morpheus.developpez.com
http://blog.developpez.com/index.php?blog=9


Steve B. said:
It's a System.Data.OleDb.OleDbException.

Looks like the database. Wouldn't the Open() fail if it was a problem with
the dB?

Should I recreate the Conn, DA and DS

Steve

Steve B. said:
Does anyone know why the DA Update() would throw an exception?

I moved the database but I updated the Conn and the DA, currently
(trying)removing/replacing DS. Is there a another direction I should be
looking in? Does it matter if I move columns in the grid (everything is a
string anyways)? Does the DS need to be udated from the DT?
***************
int rowNo = dg.CurrentRowIndex;

dt = dt .Rows[rowNo].BeginEdit();
dt = dt .Rows[rowNo][columnName] = strgCellFill;
dt = dt .Rows[rowNo].EndEdit();

string s = dt.Rows[rowNo][columnName]; // s = strgCellFill

DataRow dr = dt.Rows[rowNo];
string s1 = dr.RowState.ToString(); // s1 = "Modified"

DS dataSetChanges = getDataSetChanges();

if (dataSetChanges.HasChanges())
{
this.Conn.Open();
this.da.Update(ds); //throws an exception
this.Conn.Close();
}
 
G

Guest

I'm studing this don't know what to do yet, creates duplicate key??
Steve

Message1 ---
The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Change the data in the field or fields that contain duplicate data, remove
the index, or redefine the index to permit duplicate entries and try again.

String Message ---
System.Data.OleDb.OleDbException: The changes you requested to the table
were not successful because they would create duplicate values in the index,
primary key, or relationship. Change the data in the field or fields that
contain duplicate data, remove the index, or redefine the index to permit
duplicate entries and try again.
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable)
at businessInformation.ConfigMgmtLog.UpdateDataBase() in
c:\businessinformationsoftware\businessinformation\configmgmtlog.cs:line 2028

HelpLink ---


Source ---
Microsoft JET Database Engine

StackTrace ---
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable)
at businessInformation.ConfigMgmtLog.UpdateDataBase() in
c:\businessinformationsoftware\businessinformation\configmgmtlog.cs:line 2028

TargetSite ---
Int32 Update(System.Data.DataRow[], System.Data.Common.DataTableMapping)
Inner Exception ---

The program '[1992] businessInformation.exe' has exited with code 0 (0x0).

LEBRUN Thomas said:
It's a System.Data.OleDb.OleDbException.

Ok, but you need to catch nd display the complete error of th exception ;)

Bye

-------------------
LEBRUN Thomas
http://morpheus.developpez.com
http://blog.developpez.com/index.php?blog=9


Steve B. said:
It's a System.Data.OleDb.OleDbException.

Looks like the database. Wouldn't the Open() fail if it was a problem with
the dB?

Should I recreate the Conn, DA and DS

Steve

Steve B. said:
Does anyone know why the DA Update() would throw an exception?

I moved the database but I updated the Conn and the DA, currently
(trying)removing/replacing DS. Is there a another direction I should be
looking in? Does it matter if I move columns in the grid (everything is a
string anyways)? Does the DS need to be udated from the DT?
***************
int rowNo = dg.CurrentRowIndex;

dt = dt .Rows[rowNo].BeginEdit();
dt = dt .Rows[rowNo][columnName] = strgCellFill;
dt = dt .Rows[rowNo].EndEdit();

string s = dt.Rows[rowNo][columnName]; // s = strgCellFill

DataRow dr = dt.Rows[rowNo];
string s1 = dr.RowState.ToString(); // s1 = "Modified"

DS dataSetChanges = getDataSetChanges();

if (dataSetChanges.HasChanges())
{
this.Conn.Open();
this.da.Update(ds); //throws an exception
this.Conn.Close();
}
 
J

Jeff Louie

Steve... It sounds like your update would result in a condition not
allowed by
the database such as a row with a duplicate primary key.

Regards,
Jeff
System.Data.OleDb.OleDbException: The changes you requested to the
table were not successful because they would create duplicate values in
the
index, primary key, or relationship.<
 
G

Guest

Thanks. I use a DG and bound CB/TB adjacent to the DG to update the
DG/DS/DB. Right now, for testing purposes, instead of updating all 10 fields
of the DG/DS/DB I'm just updating one field for now and update() no longer
crashes, but that presents another problem:

That one test field (worst case) is a CB and making CB selection
(CB.selectedindex > 0) is'nt saved to the DB even though the CB selection is
collected properly and sent to updated(). If I manually type an entry at
CB.selectedindex = 0 the selection is saved to DB but then the field doesn't
update if I change the DG pointer (i.e. keeps the typed valve). I can use
CB.selectedindex = -1, then fill() again, etc, but not sure if that's the
direction. Cause for a new ADO thread
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top