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
Re: inserting records in the oracle table problem
This query is wrong, you use the following query it will work
vb Code:
string query=insert into testtable1(name,age,emailid,mobile,date) value ('mary',25,'
[email protected]','9884809887','8-apr-2007');
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
Re: inserting records in the oracle table problem
vb Code:
//Surely this code will work, try this code
SqlConnection con = new SqlConnection("type your connection string");
con.Open();
string qry="insert into tablename(name,age,mobile) values('ravi',25,1234454)";
SqlCommand cmd = new SqlCommand(qry, con);
cmd.ExecuteNonQuery();
Please rate if this code is work
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.
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)?
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