I've a WebFarm with 2 web servers which are NLBs (network load balanced).
Web1 and Web2; they are not part of a domain.
I have a third server, Server3, which is part of a domain and on the same physical network, and it has an MSAccess database which is used on the external webfarm as well as on the internal intranet. I can connect via the intranet because the DB file is on the same box from which the intranet is being served (Server3)
How can I 'connect' to the MSAccess database file on Server3 from either Web1 or Web2?
When I use the code below, I get this error:
The Microsoft Jet database engine cannot open the file '\\Server3\C$\MSAccessDBs\Database.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
Any clues?
Here's more info:
I'm using ASP.NET v1.1, using a standard OLEDb connection (referencing the database by path [see code below]).
From the ASP.NET v1.1 "web.config" file (I'll refer to this as ConnectStringA)
Expand|Select|Wrap|Line Numbers
- <appSettings>
- <add key="strConnectAccess" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Server3\C$\MSAccess\DatabaseFile.mdb"/>
- </appSettings>
... I'm pausing here.
I went to go look at the connection code and there is a direct inline connection string to another database which appears to not be failing:
\\Server3\C$\MSAccess\LogError.mdb
--> I'll refer to this as ConnectStringB,
The difference between ConnectStringA and ConnectStringB is that ConnectStringA assumes a shared folder, whereas ConnectStringB goes direct, as it includes the "\C$" element.
Well, I added the "\C$" to ConnectStringA, (now "\Server3\C$\MSAccess\DatabaseFile.mdb") and it still fails.
Yes, I would agree there is some sort of permissions error. The database is set for Shared, not Exclusive.
Here is my "connect" code (modified to protect a client's database)
Expand|Select|Wrap|Line Numbers
- Sub btnlogin_click(ByVal sender As Object, ByVal e As EventArgs)
- Dim conpw As OleDb.OleDbConnection
- Dim cmdpw As OleDb.OleDbCommand
- Dim strsql As String
- Dim dappw As OleDb.OleDbDataAdapter
- Dim dstpw As DataSet
- Dim rowpw As DataRow
- Dim bldpw As OleDb.OleDbCommandBuilder
- Dim inti As Integer
- Dim rdrpw As OleDb.OleDbDataReader
- Dim xx As String
- Dim yy As String
- Dim strmsg As String
- Dim strcounties As String
- Dim lngposition As Long
- Dim strIsCSR As String
- If txtIsCSR.Checked = "True" Then
- Session.Contents("IsUser2") = "True"
- Session.Contents("userName2") = txtUserName.Value
- Session.Contents("userPass2") = txtPassword.Value
- Response.Redirect("user2Logon.aspx")
- End If
- lngposition = InStr(txtPassword.Value, "'")
- If lngposition > 0 Then
- Response.Redirect("loginError.aspx")
- End If
- conpw = New OleDb.OleDbConnection(ConfigurationSettings.AppSettings("strConnectAccess"))
- conpw.Open()
- strsql = "SELECT * " & _
- "FROM [ User] " & _
- " WHERE ( ([ User]].UserName = '" & txtUserName.Value & "') AND ([ User].password = '" & txtPassword.Value & "') ) "
- cmdpw = New OleDb.OleDbCommand(strsql, conpw)
- rdrpw = cmdpw.executereader
- xx = 0
- While rdrpw.read
- xx = xx + 1
- strmsg = rdrpw.item("userID") + rdrpw.item("userName")
- strcounties = strcounties + strmsg
- End While
- conpw.close()
- If xx > 0 Then
- Session.Contents("counties") = txtMemberid.Value
- Response.Redirect("Here.aspx")
- Else
- If Len(Trim(Session.Contents("logintrys"))) = 0 Then
- Session.Contents("logintrys") = 0
- End If
- ctry = (Session.Contents("logintrys"))
- ltrys = CInt(ctry) + 1
- If ltrys > 6 Then
- Response.Redirect("lockout.aspx")
- End If
- ctry = CStr(ltrys)
- Session.Contents("logintrys") = ctry
- Response.Redirect("loginError.aspx")
- End If
- End Sub
The Microsoft Jet database engine cannot open the file '\\Server3\C$\MSAccessDBs\Database.mdb'. It is already opened exclusively by another user, or you need permission to view its data.