dataSet Fill problems

dataSet Fill problems

Postby treft » Sun 30 Oct 2011 12:37

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?
treft
 
Posts: 1
Joined: Sun 30 Oct 2011 12:12

Postby Shalex » Tue 01 Nov 2011 16:33

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.
Shalex
Devart Team
 
Posts: 7781
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect Universal