当前位置: 代码迷 >> ASP.NET >> VS10连接Oracle的有关问题:"Oracle.DataAccess.Client.OracleConnection"的类型初始值设定项引发错误
  详细解决方案

VS10连接Oracle的有关问题:"Oracle.DataAccess.Client.OracleConnection"的类型初始值设定项引发错误

热度:11370   发布时间:2013-02-25 00:00:00.0
VS10连接Oracle的问题:"Oracle.DataAccess.Client.OracleConnection"的类型初始值设定项引发异常.
问题补充:using Oracle.DataAccess.Client; 已经成功引用
private void btnTestConnections_Click(object sender, EventArgs e)//按钮事件
  {
  string connectionString = "Data Source=XXXX;user=XXXX;password=XXXX";//连接字符串正确
  OracleConnection oc = new OracleConnection(connectionString);
  oc.Open(); 
  string sql = "select * from goodsbase where GBID='00901002'"; 
  OracleCommand ocom = new OracleCommand(sql, oc);
  OracleDataReader reader = ocom.ExecuteReader();
  string a = "";
  if (reader.HasRows)
  {
  if (reader.Read())
  {
  a = (string)reader["GBID"];  
  }
  }
  this.lblLastGenerationDate.Text = a;
   
  reader.Close();
  oc.Close();
  }

运行起来,当我单机按钮时报此异常。

------解决方案--------------------------------------------------------
string sql = "select * from goodsbase where GBID='00901002'";去掉单引号试试
  相关解决方案