使用Visual Studio连接到数据库 [英] Connecting to database using visual studio

查看:110
本文介绍了使用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.


这篇关于使用Visual Studio连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆