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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to deny accessing from OleDb Provider when Excel is opening?

How to deny accessing from OleDb Provider when Excel is opening?

Scheduled Pinned Locked Moved Database
helptutorialquestion
4 Posts 3 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.
  • N Offline
    N Offline
    N Q H
    wrote on last edited by
    #1

    Hi all I am using Microsoft.Jet.OleDb.4.0 provider to obtaint data from Excel files. Here's the connection string and it works properly:

    string conn = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=source.xls;Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";

    The problem is that I want whenever excel file was opened or to be using by another programs, OleDb provider wouldn't access to the excel files. I guess that I have to set some properties on Extened Properties. I have googled alot but it seems nothing about it. anybody help me! thanks

    [N][Q][H]

    M _ N 3 Replies Last reply
    0
    • N N Q H

      Hi all I am using Microsoft.Jet.OleDb.4.0 provider to obtaint data from Excel files. Here's the connection string and it works properly:

      string conn = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=source.xls;Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";

      The problem is that I want whenever excel file was opened or to be using by another programs, OleDb provider wouldn't access to the excel files. I guess that I have to set some properties on Extened Properties. I have googled alot but it seems nothing about it. anybody help me! thanks

      [N][Q][H]

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Do you get an error if the file is in use? If not how do you expect the connection to detect the file is in use. If you are then trap the error and tell the user.

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • N N Q H

        Hi all I am using Microsoft.Jet.OleDb.4.0 provider to obtaint data from Excel files. Here's the connection string and it works properly:

        string conn = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=source.xls;Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";

        The problem is that I want whenever excel file was opened or to be using by another programs, OleDb provider wouldn't access to the excel files. I guess that I have to set some properties on Extened Properties. I have googled alot but it seems nothing about it. anybody help me! thanks

        [N][Q][H]

        _ Offline
        _ Offline
        _Damian S_
        wrote on last edited by
        #3

        Perhaps you are checking for the wrong thing... what you could consider doing is checking if the file is open before attempting to open it yourself... There's a nice example here[^] that I found with a simple google search - it's about half way down - the one that uses the API calls.

        I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! If you like cars, check out the Booger Mobile blog | If you feel generous - make a donation to Camp Quality!!

        1 Reply Last reply
        0
        • N N Q H

          Hi all I am using Microsoft.Jet.OleDb.4.0 provider to obtaint data from Excel files. Here's the connection string and it works properly:

          string conn = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=source.xls;Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";

          The problem is that I want whenever excel file was opened or to be using by another programs, OleDb provider wouldn't access to the excel files. I guess that I have to set some properties on Extened Properties. I have googled alot but it seems nothing about it. anybody help me! thanks

          [N][Q][H]

          N Offline
          N Offline
          N Q H
          wrote on last edited by
          #4

          this's just look like when you use

          File.OpenRead(filename)

          error will be returned when the file is opening. In my case, if the file is still opening and user can modify the content while I am trying to obtain data. That's bad isn't it?

          [N][Q][H]

          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