We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,329 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

retrieving data from Oracle 11g database and putting it in ASP.NET data grid (C#)

I have the following code for connecting to an Oracle DB

using Oracle.DataAccess.Client; // C# ODP.NET Oracle managed provider

OraDb=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=TCP)(HOST=ORASRVR)(PORT=1521))
    )
    (CONNECT_DATA=
      (SERVER=DEDICATED)
      (SERVICE_NAME=ORCL)
    )
  )



string oradb = "Data Source=//192.168.100.108;User Id=hr;Password=hr;"; // C#

string oradb = "Data Source=(DESCRIPTION="
             + "(ADDRESS=(PROTOCOL=TCP)(HOST=ORASRVR)(PORT=1521))"
             + "(CONNECT_DATA=(SERVICE_NAME=ORCL)));"
             + "User Id=hr;Password=hr;";
OracleConnection conn = new OracleConnection(oradb); // C#
OracleConnection conn = new OracleConnection(); // C#
conn.ConnectionString = oradb;

conn.Open(); // C#

string sql = " select department_name from departments where department_id = 10"; // C#
OracleCommand cmd = new OracleCommand(sql, conn);
cmd.CommandType = CommandType.Text;

conn.Close();   // C#
conn.Dispose(); // C#

but its not working. Any suggestions?

2
Contributors
1
Reply
23 Hours
Discussion Span
1 Year Ago
Last Updated
2
Views
jmapepa
Newbie Poster
1 post since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

hii..

I have no idea about oracle but then i can see two strings for connections ....check with the connection path property..

this link would help you.http://docs.oracle.com/html/A96160_01/client2.htm

kamilacbe
Junior Poster in Training
89 posts since Jun 2010
Reputation Points: 10
Solved Threads: 11
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0690 seconds using 2.7MB