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. Error with OleDb not found

Error with OleDb not found

Scheduled Pinned Locked Moved C#
helpsecurity
5 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.
  • S Offline
    S Offline
    steve_rm
    wrote on last edited by
    #1

    Hello I have a problem with the following code. It gives an error saying that the OleDb could not be found. I have included using System.OleDb at the top of my form. But still get the error. [code=vb] cnnTeacher.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False"; OleDbCommand cmdTeacher = cnnTeacher.CreateCommand(); cmdTeacher.CommandText = "Select * From Teacher Where TeacherID = txtIDNumber.text"; cmdTeacher.Parameters.Add("ID", OleDb.VarWChar, 40).Value = txtIDNumber.Text; //OleDb could not be found OleDbDataAdapter daTeacher = new OleDbDataAdapter(cmdTeacher); OleDbCommandBuilder cbTeacher = new OleDbCommandBuilder(daTeacher); daTeacher.Fill(dtTeacher); [/code] Many thanks in advance, Steve

    S 1 Reply Last reply
    0
    • S steve_rm

      Hello I have a problem with the following code. It gives an error saying that the OleDb could not be found. I have included using System.OleDb at the top of my form. But still get the error. [code=vb] cnnTeacher.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False"; OleDbCommand cmdTeacher = cnnTeacher.CreateCommand(); cmdTeacher.CommandText = "Select * From Teacher Where TeacherID = txtIDNumber.text"; cmdTeacher.Parameters.Add("ID", OleDb.VarWChar, 40).Value = txtIDNumber.Text; //OleDb could not be found OleDbDataAdapter daTeacher = new OleDbDataAdapter(cmdTeacher); OleDbCommandBuilder cbTeacher = new OleDbCommandBuilder(daTeacher); daTeacher.Fill(dtTeacher); [/code] Many thanks in advance, Steve

      S Offline
      S Offline
      smithriver
      wrote on last edited by
      #2

      I have just spent the last month fighting with OleDb, so you have my sympathy! :) 1) Have you tried "using System.Data.OleDb;" instead of "System.OleDb"? (If you're using VB.NET, doesn't it use the term "Imports" instead of "using"?) 2) Make sure the driver (in your case the MS Jet OleDb driver dll) has been installed on your system. 3) I have read that if you use a DataAdapter you do not need to do an explicit open on the connection (i.e. cnnTeacher.Open()), but if all else fails, I would give it a try. Hope this helps!

      S 1 Reply Last reply
      0
      • S smithriver

        I have just spent the last month fighting with OleDb, so you have my sympathy! :) 1) Have you tried "using System.Data.OleDb;" instead of "System.OleDb"? (If you're using VB.NET, doesn't it use the term "Imports" instead of "using"?) 2) Make sure the driver (in your case the MS Jet OleDb driver dll) has been installed on your system. 3) I have read that if you use a DataAdapter you do not need to do an explicit open on the connection (i.e. cnnTeacher.Open()), but if all else fails, I would give it a try. Hope this helps!

        S Offline
        S Offline
        steve_rm
        wrote on last edited by
        #3

        Thanks for your help I am using: using System.Data.OleDb; Opening the connection is not a problem. But l am not sure about this OleDb driver dll, how would l know that I have it installed on my computer. I hope you can help. Thanks, Steve

        S 1 Reply Last reply
        0
        • S steve_rm

          Thanks for your help I am using: using System.Data.OleDb; Opening the connection is not a problem. But l am not sure about this OleDb driver dll, how would l know that I have it installed on my computer. I hope you can help. Thanks, Steve

          S Offline
          S Offline
          smithriver
          wrote on last edited by
          #4

          To determine if a driver is installed on your system, go to: Control Panel, Administrative Tools, Data Sources (ODBC), Select the "Drivers" tab. If the driver is not listed, your best bet would be to download and register the driver from Microsoft's site. But, I think the problem could be punctuation ... there needs to be a semi-colon (";") on the inside of the ending quote mark of the connection string (as well as one outside the quote mark to end the command line). For example: sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=databaseName;"; If you are still having trouble, I would look at the "OleDb.VarWChar" variable in the Parameters statement where the error is occurring. I have not dealt with parameters, but I might hazard a guess that the the OleDb needs to be qualified (i.e. System.Data.OleDb.OleDbType.VarWChar). I have had items come up in intellisense, but did not run until qualified. Hope this helps!

          S 1 Reply Last reply
          0
          • S smithriver

            To determine if a driver is installed on your system, go to: Control Panel, Administrative Tools, Data Sources (ODBC), Select the "Drivers" tab. If the driver is not listed, your best bet would be to download and register the driver from Microsoft's site. But, I think the problem could be punctuation ... there needs to be a semi-colon (";") on the inside of the ending quote mark of the connection string (as well as one outside the quote mark to end the command line). For example: sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=databaseName;"; If you are still having trouble, I would look at the "OleDb.VarWChar" variable in the Parameters statement where the error is occurring. I have not dealt with parameters, but I might hazard a guess that the the OleDb needs to be qualified (i.e. System.Data.OleDb.OleDbType.VarWChar). I have had items come up in intellisense, but did not run until qualified. Hope this helps!

            S Offline
            S Offline
            steve_rm
            wrote on last edited by
            #5

            Hello, Thanks for your help. I managed to find the answer. I don't need the line to add parameters. So l deleted it and made a few changes and now it works fine. Below is the correct code for your own review. cnnTeacher.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False"; OleDbCommand cmdTeacher = cnnTeacher.CreateCommand(); cmdTeacher.CommandText = "Select * From Teacher Where TeacherID = '" + txtIDNumber.Text + "' "; OleDbDataAdapter daTeacher = new OleDbDataAdapter(cmdTeacher); OleDbCommandBuilder cbTeacher = new OleDbCommandBuilder(daTeacher); daTeacher.Fill(dtTeacher) steve

            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