Click here to Skip to main content
16,006,355 members
Home / Discussions / Database
   

Database

 
GeneralRe: Duplicated Value Pin
Roger Wright24-Mar-02 5:10
professionalRoger Wright24-Mar-02 5:10 
GeneralRe: Duplicated Value Pin
Mazdak24-Mar-02 6:29
Mazdak24-Mar-02 6:29 
GeneralRe: Duplicated Value Pin
James T. Johnson25-Mar-02 16:40
James T. Johnson25-Mar-02 16:40 
GeneralRe: Duplicated Value Pin
Mazdak25-Mar-02 19:35
Mazdak25-Mar-02 19:35 
GeneralProblem using a Parameterized Command as the Select Command for a Data Adapter Pin
Paulo23-Mar-02 7:17
Paulo23-Mar-02 7:17 
GeneralASP DLL PROBLEM....HELP!!!! Pin
22-Mar-02 11:18
suss22-Mar-02 11:18 
GeneralRe: ASP DLL PROBLEM....HELP!!!! Pin
Loki27-Mar-02 22:47
Loki27-Mar-02 22:47 
GeneralAnother problem in ADO.NET Pin
Mazdak22-Mar-02 9:30
Mazdak22-Mar-02 9:30 
I have a datagrid and its connected to database ,I use this funcion to save changes to
datasource from datagrid:

private void btnSave_Click(object sender, System.EventArgs e)
{
    deletedRows=null;
    updatedRows=null;
    insertedRows=null;

    try
    {

        deletedRows =myDataSet.GetChanges(System.Data.DataRowState.Deleted);
        if (((deletedRows) != (null)))
        {
            myOleDbAdapter.Update(deletedRows,"Companies");
        }


        // Get all of the updated rows and update the datastore
        updatedRows = myDataSet.GetChanges(System.Data.DataRowState.Modified);
        if (((updatedRows) != (null)))
        {
            myOleDbAdapter.Update(updatedRows,"Companies");

        }


        // Get all of the inserted rows and update the datastore
        insertedRows =myDataSet.GetChanges(System.Data.DataRowState.Added);
        if (((insertedRows) != (null)))
        {
            myOleDbAdapter.Update(insertedRows,"Companies");
        }
        myDataGrid.ReadOnly=true;

    }
    catch(Exception myE)
    {
        MessageBox.Show("Problem!!" + myE.ToString());

    }




}


For the first time it works ok but second time I unhandle error thrown:

---------------------------

---------------------------
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 WindowsApplication3.Form1.btnSave_Click(Object sender, EventArgs e) in f:\visual studio projects\projectc#\windowsapplication3\form1.cs:line 219
---------------------------
OK
---------------------------


Mazy

"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here."
Wish You Were Here-Pink Floyd-1975

GeneralADO.NET Pin
Mazdak22-Mar-02 7:44
Mazdak22-Mar-02 7:44 
GeneralRe: ADO.NET Pin
Andres Manggini22-Mar-02 8:20
Andres Manggini22-Mar-02 8:20 
GeneralRe: ADO.NET Pin
Mazdak22-Mar-02 9:34
Mazdak22-Mar-02 9:34 
GeneralRe: ADO.NET Pin
Andres Manggini22-Mar-02 10:06
Andres Manggini22-Mar-02 10:06 
GeneralRe: ADO.NET Pin
Mazdak22-Mar-02 18:26
Mazdak22-Mar-02 18:26 
GeneralRe: ADO.NET Pin
AndyG22-Mar-02 18:44
AndyG22-Mar-02 18:44 
GeneralRe: ADO.NET Pin
Mazdak22-Mar-02 19:11
Mazdak22-Mar-02 19:11 
GeneralRe: ADO.NET Pin
AndyG22-Mar-02 19:33
AndyG22-Mar-02 19:33 
GeneralRe: ADO.NET Pin
Mazdak22-Mar-02 20:18
Mazdak22-Mar-02 20:18 
QuestionHow do you deploy SQL Server solutions. Pin
Michael P Butler22-Mar-02 1:41
Michael P Butler22-Mar-02 1:41 
AnswerRe: How do you deploy SQL Server solutions. Pin
Carlos Antollini22-Mar-02 2:22
Carlos Antollini22-Mar-02 2:22 
GeneralRe: How do you deploy SQL Server solutions. Pin
Michael P Butler22-Mar-02 2:34
Michael P Butler22-Mar-02 2:34 
GeneralRe: How do you deploy SQL Server solutions. Pin
Carlos Antollini22-Mar-02 2:39
Carlos Antollini22-Mar-02 2:39 
GeneralRe: How do you deploy SQL Server solutions. Pin
Michael P Butler22-Mar-02 2:50
Michael P Butler22-Mar-02 2:50 
GeneralRe: How do you deploy SQL Server solutions. Pin
Carlos Antollini22-Mar-02 3:08
Carlos Antollini22-Mar-02 3:08 
GeneralADOCE using in evc++ Pin
Mesut21-Mar-02 21:41
Mesut21-Mar-02 21:41 
GeneralADO Recordset manipulation Pin
20-Mar-02 20:38
suss20-Mar-02 20:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.