By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

DataAdapter Update() Help

P: n/a
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();
}
Nov 16 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
What is the error message that comes with the exception ?

-------------------
LEBRUN Thomas
http://morpheus.developpez.com
http://blog.developpez.com/index.php?blog=9
"Steve B." wrote:
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();
}

Nov 16 '05 #2

P: n/a
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." wrote:
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();
}

Nov 16 '05 #3

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

Steve

"Steve B." wrote:
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." wrote:
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();
}

Nov 16 '05 #4

P: n/a
> 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." wrote:
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." wrote:
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();
}

Nov 16 '05 #5

P: n/a
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" wrote:
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." wrote:
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." wrote:
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();
}

Nov 16 '05 #6

P: n/a
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.<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #7

P: n/a
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

"Jeff Louie" wrote:
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.<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.