I used to use AR to access SQL Server and work well. recently, I switched my database to Oracle 8i. I encountered several minor problems when using AR for access. Now I want to provide the Problem description and solution, and hope to provide some help to my friends who encountered the same problem.
[1] primary key ing attributes:
Set sequence or native instead of identity.
Example: (the ID type in the table is number) [Primarykey (primarykeytype. sequence, " ID " )]
Public Int ID
{
Get { Return This . ID ;}
Set { This . ID = Value ;}
}
[2] varchar2 type ing:
When ing the string type to the varchar2 type in the table, you need to indicate the aning to ansistring in the ing property when ing, otherwise the exception will be reported once the update operation is involved: "ORA-12704: character Set mismatch ".
Example: (the name type in the table is varchar2)[Property ( " XM " , Columntype = " Ansistring " )]
Public String Name
{
Get { Return This . Name ;}
Set { This . Name = Value ;}
}
[3] execute hql statement Report "ORA-12704: Character Set mismatch" exception:
Although you have set the aning to ansistring in step [2], this exception will still be reported during hql query (simplequery) execution.
Later, we found that this exception would occur as long as simplequery in the form of passing parameters, but there is no problem in the form of literal strings. Therefore, the solution is to use the ugly string connection method,
Example: (an exception is reported when the line commented out is executed) Public Static Tuser findbyname ( String _ Name)
{
Simplequery = New Simplequery ( Typeof (Tuser ), @" From Tuser user where user. Name =' " + _ Name + " ' " );
// Simplequery query = new simplequery (typeof (Tuser), @ "from Tuser user where user. Name =? ", _ Name );
Return (Tuser []) (executequery (query )))[ 0 ];
}
Finally:
As I am only working on a small system, there must be some other problems I have not found, so many problems I have found for the moment.
At the same time, I have been wondering if my Oracle 8i character set is not set properly? Or why? (I am using Oracle dishes...) Please kindly advise me ~~