In the Oracle database (Simplified Chinese), data fields of the date type are difficult to access. The following is a record of some learning experience:
1. In the OEM of Simplified Chinese version, view the data of this type from the table data editor in the following format:
26-August-2004 03:37:36 PM, but when you insert a date to it, if you enter: 26-August-2004, the system will prompt: The month is invalid. If you enter: 26-8 months-2004, you can succeed-very strange. (The time later can be omitted. The default value is 12: 00: 00 am.) to add the time, the format is 26-8-2004 03:23:34 PM, use the Chinese "Afternoon", otherwise it will fail.
2. In the Asp.net application, if you want to obtain the date entered by the user, you must convert the date entered by the user to the preceding format, such as insert into sample values (3422, 'ssxxdd', 2003. If you use the function now to obtain the current time, and then use the insert statement "insert into mytable (indate) values (" & now & ")", the system prompts that the value is missing ?? (Why ?); If you enclose now with quotation marks, the system prompts that the format is incorrect. You have to use the program to get the current time and merge it into the correct format, for example:
Dim RZ as string = now. Day. tostring + "-" + now. Month. tostring + "month-" & now. year. tostring
Dim sqlstr as string = "insert into sample values (3233, 'xxdds', '" & RZ &"')"
However, it will not work after the time is added. I tried many methods, but I do not know the format :(
There would be no such trouble if we were using the process! For example, you have created the following process:
Create or replace procedure "gf". "sample_add"
(In_no in sample. No % type,
In_message in sample. Message % type,
In_date in date)
As
Begin
Insert into GF. Sample (No, message, indate) values (in_no, in_message, in_date );
End;
In the program, you only need to assign values to the in_date parameter using the now function:
Dim cmd as new oraclecommand ("sample_add", CN)
Cmd. commandtype = commandtype. storedprocedure
Cmd. Parameters. Add (New oracleparameter ("in_date", oracletype. datetime ))
Cmd. parameters ("in_date"). value = now
The data table can obtain the complete current date.
Haha, Oracle is really hard to do. But you still have to think about it.
We also found a method to insert data using parameters.
Dim sqlstr as string = "insert into sample values (: No,: Message,: indate )"
Dim cmd as new oraclecommand (sqlstr, CN)
Cmd. Parameters. Add (New oracleparameter ("no", oracletype. Number, 5 ))
Cmd. parameters ("no"). value = 3222
Cmd. Parameters. Add (New oracleparameter ("message", oracletype. varchar, 100 ))
Cmd. parameters ("message"). value = "xxxxxxxddddddddddd"
Cmd. Parameters. Add (New oracleparameter ("indate", oracletype. datetime ))
Cmd. parameters ("indate"). value = now
Cmd. executenonquery ()
Note: The difference between SQL Server and SQL Server is: @ No →: No