Results 1 to 7 of 7

Thread: Error, cannot find OleDb [* Resolved *]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Error, cannot find OleDb [* Resolved *]

    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.

    VB Code:
    1. cnnTeacher.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False";
    2.  
    3.                 OleDbCommand cmdTeacher = cnnTeacher.CreateCommand();
    4.                 cmdTeacher.CommandText = "Select * From Teacher Where TeacherID = txtIDNumber.text";
    5.  
    6.                 cmdTeacher.Parameters.Add("ID", OleDb.VarWChar, 40).Value = txtIDNumber.Text; //OleDb could not be found
    7.                 OleDbDataAdapter daTeacher = new OleDbDataAdapter(cmdTeacher);
    8.                 OleDbCommandBuilder cbTeacher = new OleDbCommandBuilder(daTeacher);
    9.  
    10.                 daTeacher.Fill(dtTeacher);

    Many thanks in advance,

    Steve
    Last edited by steve_rm; Oct 4th, 2004 at 10:26 PM.
    steve

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Post the EXACT error.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    Hello,

    thanks for your reply. This is the full error message:

    The type or namespace name 'OleDb' could not be found (are you missing a using directive or an assembly reference?).

    I hope you can help.

    Steve
    steve

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Code:
    using System.Data.OleDb;

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    Hello Pirate,

    Thanks for your reply. I am using

    Code:
    using System.Data.OleDb;
    Any more help with this.

    Thanks,

    Steve
    steve

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Check in the References item in the project solution explorer if you have System.Data . and also can you use fully qualified namespace in declaring OleDb objs ?

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    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.

    VB Code:
    1. cnnTeacher.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False";
    2.                 OleDbCommand cmdTeacher = cnnTeacher.CreateCommand();
    3.                 cmdTeacher.CommandText = "Select * From Teacher Where TeacherID = '" + txtIDNumber.Text + "' ";
    4.  
    5.                 OleDbDataAdapter daTeacher = new OleDbDataAdapter(cmdTeacher);
    6.                 OleDbCommandBuilder cbTeacher = new OleDbCommandBuilder(daTeacher);
    7.  
    8. daTeacher.Fill(dtTeacher)
    steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width