hello
this is the code i used to connect to the oracle database but it is not getting connected. Is there anything wrong in the code or i heard that in windows 7 the connection does not happen...can some one please help me
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OracleClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication9
{
public partial class Form1 : Form
{
// OracleCommand cmd;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
OracleConnection con;
string str = "Data Source=orcl;User Id=scott;Password=tiger;";
con = new OracleConnection(str);
con.Open();
if (con.State == ConnectionState.Open)
{
MessageBox.Show("database connected");
}
else
{
MessageBox.Show("database not connected");
}
}
Marimuthu ArigovindasamyPosted Jun 27, 2010, 10:50 PM
<appSettings>
<add key="DBConnection" value="user id= useridvalue;password=passwordvalue;data source=datasource_value"/>
appSettings>
CS:
OracleConnection dbConnection = new OracleConnection();
dbConnection.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["DBConnection"];
dbConnection.Open();
Note: Pls make sure, you have the datasource entry in ur .ORA file.
TNS entry (C:\oracle\product\10.2.0\client_1\network\ADMIN\TNSNAMES.ORA)
datasource_value =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = ON)
(FAILOVER = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = dsghjfd.com)(PORT = 1215))
(ADDRESS = (PROTOCOL = TCP)(HOST = dsghjfd.com)(PORT = 1215))
(ADDRESS = (PROTOCOL = TCP)(HOST = dsghjfd.com)(PORT = 1215))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = datasource_value.something.com)
)
)