我们正在尝试在需要访问远程Oracle数据库的Azure云服务上部署Web服务。
测试连接时,我们不断收到以下错误:
需要System.Data.OracleClient 8.1.7或更高版本。
以下是我们用于连接的代码部分:
using System.Data.OracleClient;
public string InsertUser_NOHA_UTENTI_Oracle(string cognome, string nome, string email)
{
string guid = Guid.NewGuid().ToString();
System.Configuration.ConnectionStringSettings css = System.Configuration.ConfigurationManager.ConnectionStrings["dbOracle"];
string query = "INSERT INTO NOHA_UTENTI (COGNOME,NOME,MAIL,TOKEN,STATO,DT_ISCRIZ,DT_CONF_ISCRIZ) values (@cognome, @nome, @email, @token, @stato, @dataIscrizione, @dataConfermaIscrizione)";
try
{
// create connection and command
using (OracleConnection cn = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xx.xx.xx.xx)(PORT=xxxx))(CONNECT_DATA=(SID=orcl)));User Id=xxxxxx;Password=xxxxxxx;"))
{
using (OracleCommand cmd = new OracleCommand(query, cn))
{
// define parameters and their values
cmd.Parameters.Add("@cognome", OracleType.VarChar, 50).Value = cognome;
cmd.Parameters.Add("@nome", OracleType.VarChar, 50).Value = nome;
cmd.Parameters.Add("@email", OracleType.VarChar, 50).Value = email;
cmd.Parameters.Add("@token", OracleType.VarChar, 50).Value = guid;
cmd.Parameters.Add("@stato", OracleType.VarChar, 1).Value = System.Configuration.ConfigurationManager.AppSettings["statoInAttesa"];
cmd.Parameters.Add("@dataIscrizione", OracleType.DateTime).Value = DateTime.Now;
cmd.Parameters.Add("@dataConfermaIscrizione", OracleType.DateTime).Value = null;
// open connection, execute INSERT, close connection
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
return guid;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
我们尝试不成功地遵循这些解决方案:
http://www.splinter.com.au/using-the-new-odpnet-to-access-oracle-from-c/
在Azure上成功部署类似应用程序的人能指出我们正确的方向吗?
提前致谢!