connect

From Rock3r, 8 Years ago, written in C, viewed 3'429 times.
URL https://paste.godclan.hu/view/vPKZ3POA Shorturl Error: Input provided by user is not valid Embed
Download Paste or View Raw
  1. public void ConnectToAccess()
  2. {
  3.     System.Data.OleDb.OleDbConnection conn = new
  4.         System.Data.OleDb.OleDbConnection();
  5.     // TODO: Modify the connection string and include any
  6.     // additional required properties for your database.
  7.     conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
  8.         @"Data source= C:\Documents and Settings\username\" +
  9.        @"My Documents\AccessFile.mdb";
  10.    try
  11.    {
  12.        conn.Open();
  13.        // Insert code to process data.
  14.    }
  15.        catch (Exception ex)
  16.    {
  17.        MessageBox.Show("Failed to connect to data source");
  18.    }
  19.    finally
  20.    {
  21.        conn.Close();
  22.    }
  23. }

Reply to "connect"

Here you can reply to the paste above