prasanna p

prasanna p

  • 1.3k
  • 470
  • 103k

local Msaccess database file is not connecting with Oledb and Odbc

Feb 29 2024 11:11 AM

Hi Friends,

I am not able to connect to local system Msaccess database with .mdb file with Oledb and Odbc connection.

The database have password.I tried with different solution but getting system.data.oledb is not supported on this platform error.


    string  connectionString = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\DB_BKUP\RESTSALES.mdb;Jet OLEDB:Database Password=Touchpoint;");
            conn.Open();

            using (OleDbConnection connection = new OleDbConnection(connectionString))
            {
               try
             {
                   connection.Open();

                   // Execute database operations using OleDbCommand
                   // For example, select data from a table
                    string query = "SELECT * FROM TRANSACTIONDETAILS";
                 using (OleDbCommand command = new OleDbCommand(query, connection))
                   {
                   using (OleDbDataReader reader = command.ExecuteReader())
                     {
                        while (reader.Read())
                          {
                              // Access data using reader
                              Console.WriteLine(reader["ColumnName"].ToString());
                          }
                       }
                  }
              }
               catch (Exception ex)
              {
                  Console.WriteLine("Error: " + ex.Message);
               }
            }

Please tell me how to connect to the local access db file from windows forms or WPF application

 


Answers (3)