home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_adooverview3_cpp________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2002-06-20  |  1.9 KB  |  70 lines

  1. //-----------------------------------------------------------------------
  2. //  This file is part of the Microsoft .NET SDK Code Samples.
  3. // 
  4. //  Copyright (C) Microsoft Corporation.  All rights reserved.
  5. // 
  6. //This source code is intended only as a supplement to Microsoft
  7. //Development Tools and/or on-line documentation.  See these other
  8. //materials for detailed information regarding Microsoft code samples.
  9. // 
  10. //THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
  11. //KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  12. //IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  13. //PARTICULAR PURPOSE.
  14. //-----------------------------------------------------------------------
  15.  
  16. #using <mscorlib.dll>
  17. #using <System.dll>
  18. #using <System.Data.dll>
  19.  
  20.  
  21. using namespace System;
  22. using namespace System::Data;
  23. using namespace System::Data::SqlClient;
  24.  
  25. __gc class adooverview3
  26. {
  27. public:
  28.     
  29.     void Run()
  30.   {
  31.         SqlDataReader * myReader;
  32.  
  33.     SqlConnection * mySqlConnection = new SqlConnection(S"server=(local)\\NetSDK;Integrated Security=SSPI;database=northwind");
  34.     SqlCommand * mySqlCommand = new SqlCommand("select * from customers", mySqlConnection);
  35.  
  36.     try
  37.     {
  38.       mySqlConnection->Open();
  39.       myReader = mySqlCommand->ExecuteReader();
  40.  
  41.             Console::Write("Customer ID    ");
  42.             Console::WriteLine("Company Name");
  43.  
  44.       while (myReader->Read())
  45.       {
  46.                 Console::Write(myReader->Item["CustomerID"]);
  47.                 Console::Write("      ");
  48.                 Console::WriteLine(myReader->Item["CompanyName"]);
  49.       }
  50.     }
  51.     catch(Exception * e)
  52.     {
  53.             Console::Write(e->Message);
  54.     }
  55.     myReader->Close();
  56.     mySqlConnection->Close();
  57.   }
  58. };
  59.  
  60. #ifdef _UNICODE
  61. int wmain(void)
  62. #else
  63. int main(void)
  64. #endif
  65. {
  66.     adooverview3 * myadooverview3 = new adooverview3();
  67.     myadooverview3->Run();
  68.     return 0;
  69. }
  70.