天天看點

Oracle異常處理System.Data.OracleClient.OracleException: Error while trying to retrieve text for error ORA-01036

:“System.Data.OracleClient.OracleException: Error while trying to retrieve text for error ORA-01036”,把oraComm的構造參數換成sql2的方式仍然不行。遍查代碼沒發現什麼可疑的地方,所有執行個體、教程都是這麼寫的,而且OleDb提供者能運作,為什麼OracleClient就不行了呢。

    在遍查了國外的文章後才發現問題,對于OracleClient提供者@id及?方式都不被支援。而是應該用如下方式定義:

Oracle異常處理System.Data.OracleClient.OracleException: Error while trying to retrieve text for error ORA-01036

string  sql3 = " select * from table1 where id= " :id " ;

    OracleCommand oraComm=new OracleCommand(sql3,connect);

Oracle異常處理System.Data.OracleClient.OracleException: Error while trying to retrieve text for error ORA-01036
Oracle異常處理System.Data.OracleClient.OracleException: Error while trying to retrieve text for error ORA-01036

oraComm.Parameters.AddWithValue( " :id " , 888 ); 将@符号換成:号就可以了。