home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_adooverview2_cpp________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2002-06-20  |  2.2 KB  |  67 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. // This is the main project file for VC++ application project 
  17. // generated using an Application Wizard.
  18.  
  19. #using <mscorlib.dll>
  20. #using <System.dll>
  21. #using <System.Data.dll>
  22.  
  23. using namespace System;
  24. using namespace System::Data;
  25. using namespace System::Data::SqlClient;
  26.  
  27. __gc class adooverview2
  28. {
  29. public:
  30.     void Run()
  31.   {
  32.     String * Message;
  33.  
  34.     SqlConnection *myConnection = new SqlConnection(S"server=(local)\\NetSDK;Integrated Security=SSPI;database=northwind");
  35.     SqlCommand *mySqlCommand = new SqlCommand(S"INSERT INTO Customers (CustomerId, CompanyName, Contactname, ContactTitle, Address) Values ('fd','FatDaddy', 'Penelope Smith', 'Princess','One My Way')", myConnection);
  36.     SqlCommand *mySqlCleanup = new SqlCommand(S"DELETE FROM Customers WHERE CustomerId = 'fd'", myConnection);
  37.  
  38.     try
  39.     {
  40.       myConnection->Open();
  41.       mySqlCleanup->ExecuteNonQuery();  // remove record that may have been entered previously.
  42.       mySqlCommand->ExecuteNonQuery();
  43.       Message = "FatDaddy Record inserted into Customers table in northwind.";
  44.     }
  45.     catch(Exception * e)
  46.     {
  47.         Message= String::Concat("Couldn't insert record: ", e->ToString());
  48.     }
  49.  
  50.     myConnection->Close();
  51.  
  52.     Console::Write(Message);
  53.   }
  54. };
  55.  
  56. // This is the entry point for this application
  57. #ifdef _UNICODE
  58. int wmain(void)
  59. #else
  60. int main(void)
  61. #endif
  62. {
  63.     // TODO: Please replace the sample code below with your own.
  64.     adooverview2 * myadooverview2 = new adooverview2();
  65.     myadooverview2->Run();
  66.     return 0;
  67. }