.NET程序连接Oracle的几种方式:
1,OracleConnection:
string connstr = "Provider=OraOleDb.Oracle;DataSource=orcl;userid=system;password=a123;";
string cmdstr = "select * from test";
OracleConnection orclcon = new OracleConnection("User Id=system;Password=a123;Data Source=orcl;");
try
{
orclcon.Open();
OracleCommand orclcmd = new OracleCommand(cmdstr, orclcon);
OracleDataAdapter oda = new OracleDataAdapter(orclcmd);
DataSet ds = new DataSet();
oda.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
PETSHOP连接字符串:Data Source=orcl;user id=MSPETSHOP4;password=pass@word1;min pool size=4;max pool size=4;
2,OleDbConnection