Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 848767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:59:42+00:00 2026-05-15T06:59:42+00:00

I am connecting C# with Oracle 11g. I have a DataTable which i fill

  • 0

I am connecting C# with Oracle 11g. I have a DataTable which i fill using an Oracle Data Adapter.

OracleDataAdapter da;
DataTable dt = new DataTable();

da = new OracleDataAdapter("SELECT * FROM Author", con);
da.Fill(dt);

I have few text boxes that I have databound to various rows in the data table.

txtAuthorID.DataBindings.Add("Text", dt, "AUTHORID");
txtFirstName.DataBindings.Add("Text", dt, "FIRSTNAME");
txtLastName.DataBindings.Add("Text", dt, "LASTNAME");
txtAddress.DataBindings.Add("Text", dt, "ADDRESS");
txtTelephone.DataBindings.Add("Text", dt, "TELEPHONE");
txtEmailAddress.DataBindings.Add("Text", dt, "EMAIL");

I also have a DataGridView below the Text Boxes, showing the contents of the DataTable.

dgvAuthor.DataSource = dt;

Now when I want to add a new row, i do

bm.AddNew();

where bm is defined in Form_Load as

BindingManagerBase bm;
bm = this.BindingContext[dt];

And when the save button is clicked after all the information is entered and validated, i do

this.BindingContext[dt].EndCurrentEdit();

try
{
da.Update(dt);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

However the problem comes where when I usually enter a row to the database (using SQL Plus) , I use a my_pk_sequence.nextval for the primary key. But how do i specify that when i add a new row in this method?

I catch this exception
ORA-01400: cannot insert NULL into ("SYSMAN".AUTHOR.AUTHORID") which is obvious because nothing was specified for the primary key. How do get around this? Thanx a lot in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:59:42+00:00Added an answer on May 15, 2026 at 6:59 am

    One solution is to create trigger that will automatically generate value on insert.
    Something like this:

    CREATE OR REPLACE TRIGGER trigger_name 
       BEFORE INSERT ON SYSMAN.AUTHOR.AUTHORID 
       REFERENCING 
          OLD AS OLD 
          NEW AS NEW 
       FOR EACH ROW      
       BEGIN
           SELECT my_sequence.NEXTVAL
           INTO :NEW.AUTHORID
           FROM DUAL;
       END;
    

    Edit:

    Here is quote from Wikipedia on DUAL table:

    The DUAL table is a special one-row table present by default in all Oracle database installations.

    Since DUAL table is important in ORACLE, here are some resources where you can learn about it:

    • DUAL table from Wikipedia
    • Ask Tom “All about the DUAL table”
    • StackOverflow: What is the dual table in Oracle?
    • Google query: Oracle Dual Table
    • Oracle documantation articles:
      • The Data Dictionary
      • Selecting from the DUAL Table
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first some data: we are using Oracle 11g databases. A primary database running on
When connecting to oracle server from .NET application using ADO.NET for oracle, even if
In WebSphere 6.1 I have created a datasource to an Oracle 11g instance using
I'm connecting from Oracle to different databases (MS Access, MySQL, ...). When opening the
I'm using OLEDB provider for ADO.Net connecting to an Oracle database. In my loop,
I am using Oracle 9 JDBC Thin Driver - the connection string I have
I try to connect to oracle 11g but I have problem and receive the
How would I go about connecting to oracle from F#? Is there a drive
We are debugging a 32bit application, which connects to oracle using 32bit libraries. We
I have the Oracle client, weblogic and the SOA suite 11g installed on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.