- 追加された行はこのように表示されます。
- 削除された行は
このように表示されます。
!!!VC++.NET Express から Oracleへ接続
[VC++.NET][Oracle]
*[.NET Developer Center|http://otn.oracle.co.jp/tech/dotnet/index.html]
*[Data Provider for .NET開発者ガイド|http://otndnld.oracle.co.jp/document/products/oracle10g/101/doc_v6/win.101/B15519-01/toc.htm]
!!ODP.NETの入手
::入手先
http://otn.oracle.co.jp/tech/dotnet/index.html から Oracle Data Provider for .NET 2.0 10.2.0.2.2 をダウンロードしてインストール
::VC++の設定
!VC++の設定
プロジェクトを作成し、参照設定を行う
{{ref_image vc_ora_01.JPG}}
*Oracle.DataAccess.Client;
*Oracle.DataAccess.Types;
::接続
!接続
using namespace System::Diagnostics;
using namespace Oracle::DataAccess::Client;
using namespace Oracle::DataAccess::Types;
:
OracleConnection^ conn
= gcnew OracleConnection
(L"user id=****;password=****;data source=[host name]/[service name]");
conn->Open();
Debug::Print(L"Oracle Connection Opened.");
OracleCommand^ cmd = gcnew OracleCommand(L"select * from all_tables");
cmd->Connection = conn;
OracleDataReader^ reader = cmd->ExecuteReader();
String^ ret = L"";
while (reader->Read()) {
ret += "\n" + reader->GetString(1);
}
MessageBox::Show(ret);
conn->Close();
::結果
{{ref_image vc_ora_02.JPG}}