当前位置:Gxlcms >
数据库问题 >
visual studio 2013连接Oracle 11g并获取数据:(二:实现)
visual studio 2013连接Oracle 11g并获取数据:(二:实现)
时间:2021-07-01 10:21:17
帮助过:2人阅读
void button1_Click(
object sender, EventArgs e)
{
string connectionString;
string queryString;
connectionString =
"Data Source=ORCL;User ID=scott;PassWord=tiger";
queryString =
"SELECT * FROM TEST";
OracleConnection myConnection =
new OracleConnection(connectionString);
OracleCommand myCommand =
myConnection.CreateCommand();
myCommand.CommandText =
queryString;
myConnection.Open();
OracleDataAdapter oraDA =
new OracleDataAdapter(myCommand);
DataSet ds =
new DataSet();
oraDA.Fill(ds);
myConnection.Close();
DataTable dtbl=ds.Tables[
0];
this.dataGridView1.DataSource =
dtbl;
}
(4)运行,结果如下:
和我的数据库中的数据一样
visual studio 2013连接Oracle 11g并获取数据:(二:实现)
标签: