473,385 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DataAdapter Update() Help

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
7 2552
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
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
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
> 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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third...
6
by: Geoff Pennington | last post by:
I have a class method that returns a DataAdapter. I want to access the table(s) contained in the DataAdapter. Of course, accessing the DataSets would be good enough, because I could get the tables...
13
by: Doug Bell | last post by:
Hi, I thought I had this sorted this morning but it is still a problem. My application has a DataAccess Class. When it starts, it: Connects to a DB (OLE DB) If it connects it uses an...
2
by: johnb41 | last post by:
I have a very simple application where i just want to display records from a database, and be able to edit the records. Here's the code for the "update" button: Private Sub...
11
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
1
by: Franklin M. Gauer III | last post by:
I create a simple DATAADAPTER in a webservice project. It creates the UPDATE, INSERT, DELETE commands for me - no problem. In vS2005 it creates these commands as RESOURCES in the RESX file (i.e....
2
by: Franklin M. Gauer III | last post by:
I create a simple DATAADAPTER in a webservice project. It creates the UPDATE, INSERT, DELETE commands for me - no problem. In vS2005 it creates these commands as RESOURCES in the RESX file (i.e....
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
5
by: George | last post by:
I have set DataAdapter.AcceptChangesDuringUpdate = true; However, I find that I still need to call AcceptChanges on the associated DataTable, DataTable.AcceptChanges(); Has anyone...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.