OCI-22053: overflow error caused when retreiving valid data inserted using System.Data.OracleClient
2005-07-26 14:15
543 查看
See the following example of how to insert a valid numeric value (a Decimal) using the System.Data.OracleClient that cannot be retreived using the same System.Data.OracleClient.
It is apparently some sort of bit-wise translation error between the Oracle Client and the Microsoft Data Provider. This test was run with VisualStudio2003 and Oracle 9i Client v9.2.0.4.0 connecting to Oracle Server 9.2.0.4.0, all running on Windows 2000 SP4.
It is apparently some sort of bit-wise translation error between the Oracle Client and the Microsoft Data Provider. This test was run with VisualStudio2003 and Oracle 9i Client v9.2.0.4.0 connecting to Oracle Server 9.2.0.4.0, all running on Windows 2000 SP4.
using System; using System.Data; using System.Data.OracleClient; namespace OdpTest { /// <summary> /// The following command line application code illustrates haw a value that was inserted /// using the System.Data.OracleClient causes an overflow error when retreiving it using /// the same System.Data.OracleClient. /// </summary> public class OverflowTest { private const string CONNECT_STRING = "USER ID=foo;PASSWORD=bar;DATA SOURCE=foobar"; [STAThread] private static void Main(string[] args) { using (OracleConnection conn = new OracleConnection(CONNECT_STRING)) { conn.Open(); try { using (OracleCommand createCmd = conn.CreateCommand()) { createCmd.CommandText = "create table overflow_test (num NUMBER)"; createCmd.ExecuteNonQuery(); } using (OracleCommand insertCmd = conn.CreateCommand()) { insertCmd.CommandText = "insert into overflow_test (num) values (:a)"; OracleParameter p = insertCmd.CreateParameter(); p.ParameterName = "a"; p.Value = 61M / 3M; // The magic value (there are more than just this one) p.Direction = ParameterDirection.Input; p.DbType = DbType.Decimal; insertCmd.Parameters.Add(p); Console.Error.WriteLine("Storing value: " + p.Value.ToString()); insertCmd.ExecuteNonQuery(); } using (OracleCommand selectCmd = conn.CreateCommand()) { selectCmd.CommandText = "select * from overflow_test"; DataTable overflowTest = new DataTable("overflow_test"); DataColumn num = new DataColumn("num", typeof (decimal)); overflowTest.Columns.Add(num); OracleDataAdapter oda = new OracleDataAdapter(selectCmd); oda.Fill(overflowTest); int i = 0; foreach (DataRow row in overflowTest.Rows) { Console.Error.Write("Row[{0}]:", i); for (int j = 0; j < row.Table.Columns.Count; j++) { Console.Error.Write(" {0}", row[j]); } Console.Error.WriteLine(); } i++; } } finally { using (OracleCommand deleteCmd = conn.CreateCommand()) { deleteCmd.CommandText = "drop table overflow_test"; deleteCmd.ExecuteNonQuery(); } } } } } } |
相关文章推荐
- using System.Data.OracleClient出错解决方法
- vs2010中无法using system.data.oracleclient这个引用,项目右键里也找不到
- vs2015连接oracle 11g(.net自带方式 using System.Data.OracleClient;)
- using System.Data.OracleClient与using Oracle.DataAccess.Client区别
- .Net 中访问Oracle 数据表,出现OCI-22053: overflow error
- 解决 c#连接Oracle 提示system.data.oracleclient 需要 oracle 客户端软件 8.1.7 或更高版本
- C#远程连接Oracle数据库(通过System.Data.OracleClient)
- System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本?
- System.Data.OracleClient requires Oracle client software version 8.1.7 or greater
- C# VS2010中,用微软自带的System.Data.OracleClient来连接Oracle数据库
- VS2010与System.Data.OracleClient
- vs2010下如何使【“System.Data.OracleClient.OracleConnection”已过时】 解决办法
- 解决“System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本。”(图)
- System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本的解决方法
- 解决System.Data.OracleClient requires Oracle client software version 8.1.7 or greater 问题(转)
- 解决"System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本"
- System.Data.OracleClient requires Oracle client software version 8.1.7 or greater
- System.Data.OracleClient需要Orac…
- System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本
- sql2010怎么没有 system.data.oracleclient