Cc code snippet for adding data to access database

From , 3 Years ago, written in C#, viewed 216 times.
URL https://pastebin.vip/view/1343777b
  1. using System;
  2. using System.Data;  
  3. using System.Data.OleDb;  
  4. class TestADO
  5. {  
  6.     static void Main(string[] args)  
  7.     {  
  8.         string strDSN = Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c:\test.mdb;  
  9.         string strSQL = INSERT INTO Employee(FirstName, LastName) VALUES('FirstName', 'LastName') ;  
  10.                  
  11.         // create Objects of ADOConnection and ADOCommand  
  12.         OleDbConnection conn = new OleDbConnection(strDSN);  
  13.         OleDbCommand cmd = new OleDbCommand( strSQL, conn );  
  14.         try  
  15.         {  
  16.             conn.Open();  
  17.             cmd.ExecuteNonQuery();  
  18.         }  
  19.         catch (Exception e)  
  20.         {  
  21.             Console.WriteLine(Oooops. I did it again:\n{0}, e.Message);  
  22.         }  
  23.         finally  
  24.         {  
  25.             conn.Close();  
  26.         }          
  27.     }
  28. }  
  29. //csharp/4120

Reply to "Cc code snippet for adding data to access database"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website