Results 1 to 7 of 7

Thread: inserting records in the oracle table problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    inserting records in the oracle table problem

    hi to all,
    i am inserting the record in the table using C#.Net. my query is like that

    string query =insert into TESTTABLE1 values('mmmm',25,'[email protected]','9894899987', '8-apr-2007');

    when i am using the same query in the command prompt , record was inserted without any error.But when i am inserting the same query using the c#.Net , record was inserted with wrong date('20-apr-08'). plz some body help me to solve the problem.

    thank u.

    with thanks and regards
    mmary
    Last edited by mmary; Apr 9th, 2007 at 05:56 AM.

  2. #2
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: inserting records in the oracle table problem

    This query is wrong, you use the following query it will work
    vb Code:
    1. string query=insert into testtable1(name,age,emailid,mobile,date) value ('mary',25,'[email protected]','9884809887','8-apr-2007');

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Re: inserting records in the oracle table problem

    thank u for ur reply. but it also giving the same problem. plz somebody help me to solve the problem.

    thank u.

    with thanks and regards
    mmary

  4. #4
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: inserting records in the oracle table problem

    vb Code:
    1. //Surely this code will work, try this code
    2.             SqlConnection con = new SqlConnection("type your connection string");
    3.             con.Open();
    4.             string qry="insert into tablename(name,age,mobile) values('ravi',25,1234454)";
    5.             SqlCommand cmd = new SqlCommand(qry, con);
    6.             cmd.ExecuteNonQuery();
    Please rate if this code is work

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: inserting records in the oracle table problem

    If Oracle is anything like SQL Server then you should ALWAYS use the format #M/dd/yyyy# for your dates, so try #4/08/2007# as the date literal.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: inserting records in the oracle table problem

    Oracle is not like SQL Server for Dates. Oracle expects all Dates to be in the form 'dd-Mon-YY' If any other format is sent you must specify that format in a To_Date Function

    Code:
    To_Date('4/9/2007','mm/dd/yyyy')
    That would be today.

    Do the default Oracle expects for today would be '9-Apr-07' (ensure inclued in single qoutes).

    What is the error code (the error returned by Oracle Provider)?
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Resolved Re: inserting records in the oracle table problem

    thank u . thank u very much for ur kind reply. its working fine. thank u very much.

    with thanks and regards
    mmary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width