Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help - Opened Exclusively by another user

Status
Not open for further replies.

vangundy

Programmer
Jan 29, 2005
38
CA
For some odd reason I keep getting the following err msg:

Error Type:
MSAccess (0x800A1EBA)
Microsoft Access can't open the database because it is missing, or opened exclusively by another user.

On line 57 which is:
objAccess.OpenCurrentDatabase strDbName

I have strDBName set as
strDbName = "C:\Test.mdb"

This is the correct name and the db is not opened I keep getting this err msg.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
Option Explicit
%>


<%
'Various Constants
const acNormal= "0" 'Print report
const acDesign = "1" 'open report in design (n/a in runtime)
Const acPreview = "2" 'open in preview window...probably not a good idea
const acSaveYes = "0" 'saves all objects w/out displaying dialog
const acPrompt = "1" 'prompts user --> definately a not a good thing!
const acQuitSaveNone = "2" 'exists without saving
const acViewPreview = "2" 'Print Preview
const acOutputReport = "3" 'Output the report in Snapshot format

'================================================= ================
'this will retrieve the report and display it.
'================================================= ================
Dim strDbName, strRptName, strWhere
Dim strSnapFileAb, strSnapFileRe, strFilter
' the above vars are used with the Access objects

Dim objAccess 'This is our MSAccess object

'-----------------------------------------------------------------
' Here we get a file name.
'-----------------------------------------------------------------

'Absolute path to desired Snapfile location
strSnapFileAb = "C:\test.snp"

'Relative path to desired Snapfile location
strSnapFileRe = "../db/snapfiles/test.snp"

'-----------------------------------------------------------------
'Now we get the data we need from the submitted Form
'-----------------------------------------------------------------
strDbName = "C:\Test.mdb"
strRptName = "rptSummary"
strWhere = ""
'strWhere = "po_SAP_num = 5100000240"
strFilter = ""

'-----------------------------------------------------------------
' Create an instance of access. Visible is set to false b/c
' this is running as a proccess, not as a desktop application
'-----------------------------------------------------------------
Set objAccess = Server.CreateObject("Access.Application")
objAccess.Visible = False

'-----------------------------------------------------------------
' Open the database, then the Report, and output it in Snapshot format
'-----------------------------------------------------------------
objAccess.OpenCurrentDatabase strDbName

With objAccess.DoCmd
' open in preview mode so that we can pass a where clause
' if neccesary
.OpenReport strRptName, acViewPreview, strFilter, strWhere
' now you can save the report to snapshot format
' Server.MapPath gets the current directory.
.OutputTo acOutputReport, "test", "Snapshot Format", strSnapFileAb
.Close
End With

' Clean Up
objAccess.Quit acQuitSaveNone 'acQuitSaveNone
Set objAccess = Nothing

'-----------------------------------------------------------------
'Now for the HTML, with the ActiveX plugin
'-----------------------------------------------------------------
If strSnapFileRe <> "" Then%>

<OBJECT ID="SnapshotViewer1" WIDTH=750 HEIGHT=500 CODEBASE="Snapview.ocx" CLASSID="CLSID:F0E42D60-368C-11D0-AD81-00A0C90DC8D9" VIEWASTEXT>
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="SnapshotPath" VALUE="<%=strSnapFileRe%>">
<PARAM NAME="Zoom" VALUE="0">
<PARAM NAME="AllowContextMenu" VALUE="-1">
<PARAM NAME="ShowNavigationButtons" VALUE="-1">
</OBJECT>

<%
Else
Response.Write("<P><B>An error occured while " & _
"attempting to produce your report.</B></P>")
End If
%>

 
This tends to mean that the database is, quite literally, opened by another user, potentially you. If you have opened the database in Access and have a table open (either to define it or to enter data), the database will be locked and ASP can't touch it.

If you don't have it open, open it anyway and then close it again, possibly Compact And Repairing it while it's open.

(Didn't look at your code, btw, so no guarantees that it's the problem -- it's just quite likely. During development you really have to get into the habit of closing the database before viewing a page.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top