VC++.NET Express から Oracleへ接続
ナビゲーションに移動
検索に移動
VC++.NET Express から Oracleへ接続
ODP.NETの入手
入手先
http://otn.oracle.co.jp/tech/dotnet/index.html から Oracle Data Provider for .NET 2.0 10.2.0.2.2 をダウンロードしてインストール
VC++の設定
接続
- 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();
結果
© 2006 矢木浩人