473,396 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

to_date function

Hi

when i try to use to_date function in C# codebehind, i am getting to_date
doesnt exist in class or namespace error.

i am trying to use something similar to
INSERT INTO OracleTypesTable VALUES ( 'test', 2, to_date('2000-01-11
12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";

ref link:
http://msdn.microsoft.com/library/de...classtopic.asp

i am using System.data.oracleclient

- Ganesh
any ideas?

Nov 19 '05 #1
5 4589
gane kol wrote:
Hi

when i try to use to_date function in C# codebehind, i am getting to_date
doesnt exist in class or namespace error.

i am trying to use something similar to
INSERT INTO OracleTypesTable VALUES ( 'test', 2, to_date('2000-01-11
12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";

ref link:
http://msdn.microsoft.com/library/de...classtopic.asp

i am using System.data.oracleclient

- Ganesh
any ideas?


that to_date function is Oracle sql, not C#. You might want to try
DateTime.Parse or DateTime.ParseExact.

--
Hans Kesting
Nov 19 '05 #2
But if you see the microsoft example,
they have used the to_date in c# code
---------------------------------------------
public void Setup(string connectionString)
{
OracleConnection conn = new OracleConnection(connectionString);
try
{
conn.Open();
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText ="CREATE TABLE OracleTypesTable (MyVarchar2
varchar2(3000),MyNumber number(28,4) PRIMARY KEY ,MyDate date, MyRaw
raw(255))";
cmd.ExecuteNonQuery();
cmd.CommandText ="INSERT INTO OracleTypesTable VALUES ( 'test', 2,
to_date('2000-01-11 12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";
cmd.ExecuteNonQuery();
cmd.CommandText="SELECT * FROM OracleTypesTable";
}
catch(Exception)
{
}
finally
{
conn.Close();
}
}
--------------------------------------------------
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
gane kol wrote:
Hi

when i try to use to_date function in C# codebehind, i am getting to_date doesnt exist in class or namespace error.

i am trying to use something similar to
INSERT INTO OracleTypesTable VALUES ( 'test', 2, to_date('2000-01-11
12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";

ref link:
http://msdn.microsoft.com/library/de...classtopic.asp
i am using System.data.oracleclient

- Ganesh
any ideas?


that to_date function is Oracle sql, not C#. You might want to try
DateTime.Parse or DateTime.ParseExact.

--
Hans Kesting

Nov 19 '05 #3
No they haven't, the double quoted string starting after CommandText
contains the to_date oracle functon, so the to_date isn't a c# function,
it's passed to the db to execute.

"gane kol" <ga*****@softca.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
But if you see the microsoft example,
they have used the to_date in c# code
---------------------------------------------
public void Setup(string connectionString)
{
OracleConnection conn = new OracleConnection(connectionString);
try
{
conn.Open();
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText ="CREATE TABLE OracleTypesTable (MyVarchar2
varchar2(3000),MyNumber number(28,4) PRIMARY KEY ,MyDate date, MyRaw
raw(255))";
cmd.ExecuteNonQuery();
cmd.CommandText ="INSERT INTO OracleTypesTable VALUES ( 'test', 2,
to_date('2000-01-11 12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";
cmd.ExecuteNonQuery();
cmd.CommandText="SELECT * FROM OracleTypesTable";
}
catch(Exception)
{
}
finally
{
conn.Close();
}
}
--------------------------------------------------
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
gane kol wrote:
> Hi
>
> when i try to use to_date function in C# codebehind, i am getting to_date > doesnt exist in class or namespace error.
>
> i am trying to use something similar to
> INSERT INTO OracleTypesTable VALUES ( 'test', 2, to_date('2000-01-11
> 12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";
>
> ref link:
> http://msdn.microsoft.com/library/de...classtopic.asp >
> i am using System.data.oracleclient
>
> - Ganesh
> any ideas?
>
>
>


that to_date function is Oracle sql, not C#. You might want to try
DateTime.Parse or DateTime.ParseExact.

--
Hans Kesting


Nov 19 '05 #4
That is because they have the entire query inside a string so C# does not
process it at all. It is possible that you do not and therefore C# is
trying to process it. Make sure your to_date is within the double quotes.
That way it is simply passed to the database for processing.

"gane kol" <ga*****@softca.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
But if you see the microsoft example,
they have used the to_date in c# code
---------------------------------------------
public void Setup(string connectionString)
{
OracleConnection conn = new OracleConnection(connectionString);
try
{
conn.Open();
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText ="CREATE TABLE OracleTypesTable (MyVarchar2
varchar2(3000),MyNumber number(28,4) PRIMARY KEY ,MyDate date, MyRaw
raw(255))";
cmd.ExecuteNonQuery();
cmd.CommandText ="INSERT INTO OracleTypesTable VALUES ( 'test', 2,
to_date('2000-01-11 12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";
cmd.ExecuteNonQuery();
cmd.CommandText="SELECT * FROM OracleTypesTable";
}
catch(Exception)
{
}
finally
{
conn.Close();
}
}
--------------------------------------------------
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
gane kol wrote:
Hi

when i try to use to_date function in C# codebehind, i am getting to_date doesnt exist in class or namespace error.

i am trying to use something similar to
INSERT INTO OracleTypesTable VALUES ( 'test', 2, to_date('2000-01-11
12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";

ref link:

http://msdn.microsoft.com/library/de...classtopic.asp

i am using System.data.oracleclient

- Ganesh
any ideas?


that to_date function is Oracle sql, not C#. You might want to try
DateTime.Parse or DateTime.ParseExact.

--
Hans Kesting


Nov 19 '05 #5
Thanks it worked. with the quotes..
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
That is because they have the entire query inside a string so C# does not
process it at all. It is possible that you do not and therefore C# is
trying to process it. Make sure your to_date is within the double quotes.
That way it is simply passed to the database for processing.

"gane kol" <ga*****@softca.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
But if you see the microsoft example,
they have used the to_date in c# code
---------------------------------------------
public void Setup(string connectionString)
{
OracleConnection conn = new OracleConnection(connectionString);
try
{
conn.Open();
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText ="CREATE TABLE OracleTypesTable (MyVarchar2
varchar2(3000),MyNumber number(28,4) PRIMARY KEY ,MyDate date, MyRaw
raw(255))";
cmd.ExecuteNonQuery();
cmd.CommandText ="INSERT INTO OracleTypesTable VALUES ( 'test', 2,
to_date('2000-01-11 12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";
cmd.ExecuteNonQuery();
cmd.CommandText="SELECT * FROM OracleTypesTable";
}
catch(Exception)
{
}
finally
{
conn.Close();
}
}
--------------------------------------------------
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
gane kol wrote:
> Hi
>
> when i try to use to_date function in C# codebehind, i am getting

to_date
> doesnt exist in class or namespace error.
>
> i am trying to use something similar to
> INSERT INTO OracleTypesTable VALUES ( 'test', 2, to_date('2000-01-11
> 12:54:01','yyyy-mm-dd hh24:mi:ss'), '0001020304' )";
>
> ref link:
>

http://msdn.microsoft.com/library/de...classtopic.asp
>
> i am using System.data.oracleclient
>
> - Ganesh
> any ideas?
>
>
>

that to_date function is Oracle sql, not C#. You might want to try
DateTime.Parse or DateTime.ParseExact.

--
Hans Kesting



Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: KULJEET | last post by:
hi i have a table c_table with two columns no, date it contains records no n_date 1 10-AUG-03 2 21-AUG-03
1
by: Amin Schoeib | last post by:
Hi, Can somebody tell me why this query don't work when I use to_date Instead of to_char By using to_char: select to_char(last_day(cast(current_date - interval '1 month' as...
1
by: kaab kaoutar | last post by:
Hi, A client is using postgresql 7.1.3, and to_date() and to_timestamp() functions fail sometimes,However they never do in postgresql 7.3.2. Are these bugs? Thx ...
2
by: gimme_this_gimme_that | last post by:
Assuming data is being stored in a DB2 TIMESTAMP what is the equivalent of Oracle's to_date function : to_date('03/04/2005','MM/DD/YYYY') It's OK if MM/DD/YYYY is the only supported format....
1
by: TANUJ | last post by:
i m working on oracle forms 6i n enable to fetch the record in time format. on form, field type is date with format mask hh24:mi but when i fetch it using to_char function nd trans it into...
3
rsrinivasan
by: rsrinivasan | last post by:
hi, I used the following query, select to_date('31-12-2006 23:34:59','DD-MM-YYYY HH24:MI:SS') from dual; but i get only 31-DEC-06 why i did not get the time....
0
by: woodsc | last post by:
Hi all, I am trying to optimize the queries in my application. Is there a performance difference between (to_char(myDate,format) < myString) and (myDate < to_date(myString, format)). ex. ...
5
by: arulkumara | last post by:
Hi, I want to diaplay hi message if system date is equl to given date. I tried one simple script. But it doesn't show any output what is problem with to_date function. script:...
4
by: hydroraven | last post by:
Hello all, I am trying to use the TO_DATE function to convert a string to a date so that I can perform periodic maintenance on a table based upon the date. Here is the SQL statement. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.