Home > Net >  Vs2015c # query oracle10g gibberish
Vs2015c # query oracle10g gibberish

Time:10-02

Refer to the Oracle. ManagedDataAccess. DLL
Database for 32-bit 10 g, character set for AMERICAN_AMERICA. WE8ISO8859P1
Can query to the data, but some Chinese characters were garbled,
Seek the solution, thank you,
The code is as follows:
Public string getItemInfo (string Code)
{
_putenv (" NLS_LANG=AMERICAN_AMRICA. WE8ISO8859P1 "); It's no use//
String returnstr="";
Environment. The SetEnvironmentVariable (" NLS_LANG ", "AMERICAN_AMERICA. WE8ISO8859P1", EnvironmentVariableTarget. Process); It's no use//

//Create a connection to the Oracle
OracleConnection con=new OracleConnection ();
//Web. Config the connection string
Con. The ConnectionString=System. The Configuration. The ConfigurationManager. ConnectionStrings [r]. "the conn" ConnectionString;
Try
{
Con. The Open ();

OracleGlobalization sessionGlob=con. GetSessionInfo (); It's no use//
SessionGlob. Language="AMERICAN"; It's no use//
Con. SetSessionInfo (sessionGlob); It's no use//

OracleCommand CMMD=new OracleCommand (" select * from VIEW_ITEMINFO where code='" + code + "' ", con);
OracleDataAdapter oa=new OracleDataAdapter (CMMD);

System. Data. The DataSet ds=new System. The Data. The DataSet ();
Oa. The Fill (ds, "ItemInfo");

Foreach (System. Data. The DataRow row in ds. The Tables [0]. Rows)
{
Foreach (System. Data. The DataColumn column in ds. The Tables [0]. Columns)
{
Returnstr=returnstr + row (column) + "\ t";
}
}
Return returnstr;
}
Catch
{
Return "open!" ;
}
The finally
{
Con. The Close ();
Con. The Dispose ();
}
}

CodePudding user response:

You in the oracle client lookup table is garbled

CodePudding user response:

PLSQL query normal, Oracle. ManagedDataAccess. DLL is not don't have to install the client?
  •  Tags:  
  • C#
  • Related