Page 1 of 1

dataSet Fill problems

Posted: Sun 30 Oct 2011 12:37
by treft
Hello,

Assume I have Table "Category" with two columns "CategoryID" and "CategoryName" and I want to add new row and then update dataSet.

At the beginning I have 2 rows:
CategoryID CategoryName
"1" "first"
"2" "second"

Before inserting I invoke Fill method to update dataSet with information:
uniCategoryTableAdapter.Fill(dataSet, "Category");
(it works, fill out dataSet whole Category table)

then I insert third row:
string insertString = @"
INSERT INTO Category
(CategoryID, CategoryName)
VALUES ('3', 'third')";

then trying to fill the dataSet and I get exception:
Duplicate entry "3" for key "PRIMARY"..

Any ideas how to solve the problem?

Posted: Tue 01 Nov 2011 16:33
by Shalex
We cannot reproduce the duplicate entry problem with dotConnect Universal v 3.20.65 using the following code:

Code: Select all

            UniConnection conn = new UniConnection("Provider=Oracle;User Id=scott;Password=tiger;Server=orcl1120;Home=OraClient11g_home2;");
            UniDataAdapter uniCategoryTableAdapter = new UniDataAdapter("Select * from Category", conn);
            
            DataSet dataSet = new DataSet();
            uniCategoryTableAdapter.Fill(dataSet, "Category");

            foreach (DataRow rows in dataSet.Tables["Category"].Rows)
            {
                foreach (DataColumn cols in dataSet.Tables["Category"].Columns)
                    Console.Write(rows[cols] + "\t");
                Console.WriteLine();
            }
            dataSet.Clear();

            string insertString = @" 
            INSERT INTO Category 
            (CategoryID, CategoryName) 
            VALUES ('3', 'third')";
            Console.WriteLine();

            UniCommand comm = new UniCommand(insertString,conn);
            conn.Open();
            comm.ExecuteNonQuery();
            conn.Close();

            uniCategoryTableAdapter.Fill(dataSet, "Category");

            foreach (DataRow rows in dataSet.Tables["Category"].Rows)
            {
                foreach (DataColumn cols in dataSet.Tables["Category"].Columns)
                    Console.Write(rows[cols] + "\t");
                Console.WriteLine();
            }
Tell us how we should modify this sample or send us your small test project to reproduce the issue in our environment.