使用Visual Studio连接到数据库

使用Visual Studio连接到数据库

问题描述:

我正在尝试使用C#编码连接到oracle数据库,但它说.没有听众.我没有线索.任何人都可以为我提供一个好的解决方案.我也想看看确切的编码.以下是我的代码

I''m trying to connect to the oracle database using C# coding but it says . no listener.I have no clue.Can any one provide me with a good solution please.I want to see the exact coding too please. The following is my code

string oradb = "Data Source=oradb;User Id=hr;Password=oracle;";
        OracleConnection conn = new OracleConnection(oradb);
        conn.Open();
        string sql = "select VALUE from APPBASE.STAGE_LOCALE where LOCALE_ID = 2";
        OracleCommand cmd = new OracleCommand(sql, conn);
        cmd.CommandType = CommandType.Text;
        OracleDataReader dr = cmd.ExecuteReader(); 
        dr.Read();
        Label1.Text = dr["VALUE"].ToString();

        conn.Close();   
        conn.Dispose(); 

我假设您有这个问题.

这是该页面的报价.
基本上,Forms服务器找不到侦听器.首先检查tnsnames.ora文件,并确保它指向正确的服务器和端口.如果Forms服务器在另一台计算机上,请在命令提示符下使用tnsping测试TNS解析.最后,检查监听器.
I''m assuming you have this issue.

This is quote from that page.
Basically the Forms server could not find the listener. First check the tnsnames.ora file and ensure that it points to the correct server and port. If the Forms server is on another machine, test the TNS resolve with tnsping from the command prompt. Finally, check the listener.