Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Why is my .mdb connection not working?

Why is my .mdb connection not working?

Scheduled Pinned Locked Moved C#
databasehelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    I try to get some data from a .mdb file, but it fails with a realy weird and long exception, here is my code: public DataSet getTranslation(int language) { DataSet translations = new DataSet(); String connes = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Johan\\My Documents\\languageDB1_00.mdb"; String sql = ("SELECT Translation, PhraseKey FROM Translation WHERE languageID = " + language + ";"); OleDbConnection conn = null; conn = new OleDbConnection(connes); //"SELECT Translation, PhraseKey FROM Translation WHERE languageID = " + language + ";"; try { OleDbCommand command = new OleDbCommand(sql, conn); OleDbDataAdapter adapter = new OleDbDataAdapter(command); conn.Open(); adapter.Fill(translations, "Translation"); return translations; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); return null; } finally { conn.Close(); } } The exeption message begins with: IErrorInfo.GetDescription failed with E_FAIL (0x80004005) please help... john

    M 1 Reply Last reply
    0
    • A Anonymous

      I try to get some data from a .mdb file, but it fails with a realy weird and long exception, here is my code: public DataSet getTranslation(int language) { DataSet translations = new DataSet(); String connes = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Johan\\My Documents\\languageDB1_00.mdb"; String sql = ("SELECT Translation, PhraseKey FROM Translation WHERE languageID = " + language + ";"); OleDbConnection conn = null; conn = new OleDbConnection(connes); //"SELECT Translation, PhraseKey FROM Translation WHERE languageID = " + language + ";"; try { OleDbCommand command = new OleDbCommand(sql, conn); OleDbDataAdapter adapter = new OleDbDataAdapter(command); conn.Open(); adapter.Fill(translations, "Translation"); return translations; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); return null; } finally { conn.Close(); } } The exeption message begins with: IErrorInfo.GetDescription failed with E_FAIL (0x80004005) please help... john

      M Offline
      M Offline
      Mahesh Kumar V K
      wrote on last edited by
      #2

      Hello John, The problem is because of the usage of the keyword "Translation" as in OLEDB. If you change the SQL to String sql = "(SELECT [Translation], PhraseKey FROM [Translation] " + "WHERE languageID = " + language + ")"; the snippet will work fine. Regards Mahesh

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups