Why compiler go to suspend mode when want to open database?
Posted
by rima
on Stack Overflow
See other posts from Stack Overflow
or by rima
Published on 2010-05-27T02:43:04Z
Indexed on
2010/05/27
2:51 UTC
Read the original article
Hit count: 321
Dear friend I try to connect to database with a less line for my connection string... I find out s.th in oracle website but i dont know Why when the compiler arrive to the line of open database do nothing????!it go back to GUI,but it like hanging...please help me to solve it.
p.s.Its funny the program didnt get me any exception also!
these service is active in my computer:
> Oracle ORCL VSS Writer Service Start
> OracleDBConsolrorcl
> OracleJobSchedulerORCL Start
> OracleOraDB11g+home1TNSListener Start
> oracleServiceORCL Start
try
{
/**
*
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rima-PC)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)*/
string oradb = "Data Source=(DESCRIPTION="
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=rima-PC)(PORT=1521)))"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));"
+ "User Id=bird_artus;Password=123456;";
//string oradb = "Data Source=OraDb;User Id=scott;Password=tiger;";
string oradb1 = "Data Source=ORCL;User Id=scott;Password=tiger;"; // C#
OracleConnection con = new OracleConnection();
con.ConnectionString = oradb1;
String command = "select dname from dept where deptno = 10";
MessageBox.Show(command);
OracleDataAdapter oda = new OracleDataAdapter();
oda.SelectCommand = new OracleCommand();
oda.SelectCommand.Connection = con;
oda.SelectCommand.CommandText = command;
con.Open();
oda.SelectCommand.ExecuteNonQuery();
DataSet ds = new DataSet();
oda.Fill(ds);
Console.WriteLine(ds.GetXml());
dataGridView1.DataSource = ds;
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString()+Environment.NewLine+ ex.StackTrace.ToString());
}
© Stack Overflow or respective owner