473,242 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

how to connect to an Access DB from a webfarm?

9
Scenario:
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
  1.  <appSettings>
  2.     <add key="strConnectAccess" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Server3\C$\MSAccess\DatabaseFile.mdb"/>
  3. </appSettings>
  4.  
actual "connect" code:
... 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
  1.     Sub btnlogin_click(ByVal sender As Object, ByVal e As EventArgs)
  2.         Dim conpw As OleDb.OleDbConnection
  3.         Dim cmdpw As OleDb.OleDbCommand
  4.         Dim strsql As String
  5.  
  6.         Dim dappw As OleDb.OleDbDataAdapter
  7.         Dim dstpw As DataSet
  8.         Dim rowpw As DataRow
  9.         Dim bldpw As OleDb.OleDbCommandBuilder
  10.         Dim inti As Integer
  11.         Dim rdrpw As OleDb.OleDbDataReader
  12.  
  13.         Dim xx As String
  14.         Dim yy As String
  15.         Dim strmsg As String
  16.         Dim strcounties As String
  17.         Dim lngposition As Long
  18.         Dim strIsCSR As String
  19.  
  20.         If txtIsCSR.Checked = "True" Then
  21.             Session.Contents("IsUser2") = "True"
  22.             Session.Contents("userName2") = txtUserName.Value
  23.             Session.Contents("userPass2") = txtPassword.Value
  24.             Response.Redirect("user2Logon.aspx")
  25.         End If
  26.  
  27.         lngposition = InStr(txtPassword.Value, "'")
  28.         If lngposition > 0 Then
  29.             Response.Redirect("loginError.aspx")
  30.         End If
  31.  
  32.  
  33.         conpw = New OleDb.OleDbConnection(ConfigurationSettings.AppSettings("strConnectAccess"))
  34.         conpw.Open()
  35.  
  36.  
  37.         strsql = "SELECT * " & _
  38.         "FROM [ User] " & _
  39.         " WHERE ( ([ User]].UserName = '" & txtUserName.Value & "') AND ([ User].password = '" & txtPassword.Value & "') )  "
  40.  
  41.         cmdpw = New OleDb.OleDbCommand(strsql, conpw)
  42.         rdrpw = cmdpw.executereader
  43.  
  44.         xx = 0
  45.         While rdrpw.read
  46.             xx = xx + 1
  47.             strmsg = rdrpw.item("userID") + rdrpw.item("userName")
  48.             strcounties = strcounties + strmsg
  49.         End While
  50.  
  51.         conpw.close()
  52.  
  53.         If xx > 0 Then
  54.             Session.Contents("counties") = txtMemberid.Value
  55.             Response.Redirect("Here.aspx")
  56.         Else
  57.             If Len(Trim(Session.Contents("logintrys"))) = 0 Then
  58.                 Session.Contents("logintrys") = 0
  59.             End If
  60.             ctry = (Session.Contents("logintrys"))
  61.             ltrys = CInt(ctry) + 1
  62.             If ltrys > 6 Then
  63.                 Response.Redirect("lockout.aspx")
  64.             End If
  65.             ctry = CStr(ltrys)
  66.             Session.Contents("logintrys") = ctry
  67.             Response.Redirect("loginError.aspx")
  68.         End If
  69.  
  70.     End Sub
  71.  
So, in all, this error [below] is occuring, it does point to "permissions" of some kind. Thing is, how to I "connect" from a webfarm not on a domain to a server (Server3) which is on a domain? Is there a way to "mount" the shared folder at system startup and mapped to a drive letter (e.g. no user logon)?

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.
Feb 21 '07 #1
1 2012
kenobewan
4,871 Expert 4TB
Here is an article that may help:
How To: Connect to SQL Server Using SQL Authentication in ASP.NET 2.0

Please remember the connection to another server is going to be very different to that of a db on the same machine and may need to involve a domain or IP address...
Feb 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: mayamorning123 | last post by:
A comparison among six VSS remote tools including SourceOffSite , SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET To view the full article, please visit...
2
by: Christopher D. Wiederspan | last post by:
We are getting ready to move an ASP.NET application off of a single development machine and onto a "webfarm". Basically our webfarm is a bunch of identical servers with the load-balancing provided...
5
by: Fabio R. | last post by:
To support a webfarm scenario, I'd like to store a global array (serialized) in a file on a network share. In this array there is a list of pages "locked" by other users so I need to read this...
3
by: Fabio R. | last post by:
I'm developing a web application that needs to support a webfarm scenario so I've used a filecachedependency on a shared folder (for now, always in my local machine) to clear cache on all...
0
by: Komil | last post by:
Hey Guys, We are using a webfarm environment to host our current site. There are three machine involved in this webfarm. I have copied the same machinekey information that was generated from...
6
by: Prabha | last post by:
hi i am building an webfarm application. Can anyone tell me what is the best method of passing values across page? Does using stateserver cause any issues?
1
by: Prabha | last post by:
Hi, My appliaction is hosted in webfarm, how to upload a file to all the server in webfarm. Please help me, its very urgent. Millions of advance thanx. Regards
11
by: GNoter | last post by:
Is there any way to set up connecting to an MS Access file on a 3rd server (which is on a domain) from a Web Farm (which is not on the domain)? Hardware/OS: Windows Server 2003 Web Farm (two web...
12
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
Is there any doc to config webfarm for asp.net 3.5 app? I have found below article: PRB: Session State Is Lost in Web Farm If You Use SqlServer or StateServer Session Mode...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.