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. c# error

c# error

Scheduled Pinned Locked Moved C#
databasecsharphelp
21 Posts 5 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.
  • U User3490

    i have 2 connectionstring in c# and 2 connection with 2 different access database in this query i use only one access db and one connection string but when i run the program it appears an error that say that could not found file dbfile.accdb what is the problem ? public bool findrefyear( string refyear) { bool findyear = false; //create new new access connection to the database OleDbConnection connd = new OleDbConnection(connection2); //Set the access command string OleDbCommand Cmd = new OleDbCommand("SELECT ReferenceYear FROM Questionnaires_Table1 Where ReferenceYear = '" + refyear + "';", connd); try { connd.Open(); Cmd.ExecuteNonQuery(); connd.Close(); findyear = true; } catch (OleDbException e) { MessageBox.Show(e.Message.ToString()); } i call the above code with this code: ----------------------------------------- ...

    if (txtdateref.Text != "" )
    {

                       bool find\_data = qhandler.findrefyear(txtdateref.Text);
                if (find\_data == false)
                  {
    
                   MessageBox.Show(" the record is not here ", "", MessageBoxButtons.OK);
                  }
    
                 else{
               MessageBox.Show(" the record is here ", "", MessageBoxButtons.OK);
                     }
    

    }

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #21

    zebra88 wrote:

    what is the problem ?

    Dunno. Does "error" mean that it throws an exception that the access database cannot be found? If yes, then there's an error in your connectionstring. If no, does "error" mean that it displays the message "the record is not here"? Further, a "select" statement is a query. One would use the ExecuteReader method to read the dataset.

    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

    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