本文整理汇总了C#中System.Data.OracleClient.OracleConnection.GetSessionDateFormat方法的典型用法代码示例。如果您正苦于以下问题:C# OracleConnection.GetSessionDateFormat方法的具体用法?C# OracleConnection.GetSessionDateFormat怎么用?C# OracleConnection.GetSessionDateFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OracleClient.OracleConnection
的用法示例。
在下文中一共展示了OracleConnection.GetSessionDateFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bind
internal void Bind (OciStatementHandle statement, OracleConnection connection)
{
if (bindHandle == null)
bindHandle = new OciBindHandle ((OciHandle) statement);
IntPtr tmpHandle = bindHandle.Handle;
if (Direction != ParameterDirection.Input)
AssertSizeIsSet ();
if (!sizeSet)
size = InferSize ();
byte[] bytes = null;
int status = 0;
int indicator = 0;
OciDataType bindType = ociType;
IntPtr bindValue = IntPtr.Zero;
int bindSize = size;
int rsize = 0;
if (value == DBNull.Value) {
indicator = 0;
bindType = OciDataType.VarChar2;
bindSize = 0;
}
else {
// TODO: do other data types and oracle data types
// should I be using IConvertible to convert?
if (oracleType == OracleType.DateTime) {
string oraDateFormat = connection.GetSessionDateFormat ();
string sysDateFormat = OracleDateTime.ConvertOracleDateFormatToSystemDateTime (oraDateFormat);
string sDate = "";
DateTime dt = DateTime.MinValue;
if (value is String) {
sDate = (string) value;
dt = DateTime.Parse (sDate);
}
else if (value is DateTime)
dt = (DateTime) value;
else if (value is OracleString) {
sDate = (string) value;
dt = DateTime.Parse (sDate);
}
else if (value is OracleDateTime) {
OracleDateTime odt = (OracleDateTime) value;
dt = (DateTime) odt.Value;
}
else
throw new NotImplementedException (); // ?
sDate = dt.ToString (sysDateFormat);
rsize = 0;
// Get size of buffer
OciCalls.OCIUnicodeToCharSet (statement.Parent, null, sDate, out rsize);
// Fill buffer
bytes = new byte[rsize];
OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, sDate, out rsize);
bindType = OciDataType.VarChar2;
//bindValue = Marshal.StringToHGlobalAnsi (sDate);
bindSize = sDate.Length;
}
else if (oracleType == OracleType.Blob) {
bytes = (byte[]) value;
bindType = OciDataType.LongRaw;
bindSize = bytes.Length;
}
else if (oracleType == OracleType.Clob) {
string v = (string) value;
rsize = 0;
// Get size of buffer
OciCalls.OCIUnicodeToCharSet (statement.Parent, null, v, out rsize);
// Fill buffer
bytes = new byte[rsize];
OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, v, out rsize);
bindType = OciDataType.Long;
bindSize = bytes.Length;
}
else if (oracleType == OracleType.Raw) {
byte[] val = value as byte[];
bindValue = Marshal.AllocHGlobal (val.Length);
Marshal.Copy (val, 0, bindValue, val.Length);
bindSize = val.Length;
}
else {
string svalue = value.ToString ();
rsize = 0;
// Get size of buffer
OciCalls.OCIUnicodeToCharSet (statement.Parent, null, svalue, out rsize);
// Fill buffer
bytes = new byte[rsize];
OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, svalue, out rsize);
//.........这里部分代码省略.........