I need to connect to an access database file from my web application. The access database file is present on a different server. Is there any way of connecting to the access database file? Is it possible? I tried searching but could not found something to start with. I can connect to something present in the server where my web application is located. I need an approach.
You need a file share to the remote server. You can pass a full UNC name in the access connection string, sucn as:
Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source="\\server\share\Filename.accdb";Mode=Share Deny None
You will need to have the appropriate NTFS and Share permissions on the file. (Read/write)
Related
Well, I've been working on my server with a method like the following:
System.Web.HttpContext.Current.Server.MapPath("/path/something");
... and it's been working so far. Nevertheless, now I've encountered an issue. The thing is, I need to write a file that's located on an external server. Is there a method in C# to do this?
Server.mappath is designed to convert web based paths to local paths based on the location of the webroot, and is not strictly speaking relevant when trying to access external resources.
The only exception being when a remote file location is used as part of a websites file system. E.G. If your website has a folder in it called "/remotefiles/", and within IIS you have mapped this folder to a remote network path. MapPath would work as normal and you will retrieve a full UNC path.
If the server you want to access is on the same network as your web server but not referenced as part of your webroot, then you should look at directly referencing the location in question using a full UNC path. E.G. "\\ExternalServer\CDrive\SomeStuff\".
If the server is remotely accessed over a wider network, then you will need to look into another form of access.
I have a remote hosted website with a MySQL database.
I am trying to access that database from a small C# program.
What I've tried:
Referencing the MySQL DLL in the project
Using MySQL connection strings
Disabling my firewall
Adding my IP address to the Remote MySQL Databases in the site's cPanel
What I'm getting:
Access denied for user blabla#mycomputerip in the Visual Studio console
What boggles my mind:
How can I find out if my webhosting service allows remote connections to the DB?
Do I really need to connect with PuTTy to the server and tweak the configs?
^ if so, do I even have access to do that?
LATER EDIT:
Interesting enough. If I do
GRANT ALL PRIVILEGES ON *.* TO 'myuser'#'%' WITH GRANT OPTION;
it throws me this:
#1045 - Access denied for user 'blabla'#'localhost' (using password: YES)
Common sense should tell you that my username is not actually 'blabla'.
LATER LATER EDIT:
I don't have privileges to CREATE USER, nor do I have SSH access via PuTTy or so.
Does this basically mean that it's my hosting's fault that I can't connect from a remote location to the DB?
Have a look at the users in your mysql database. A couple things to check:
With cPanel on shared hosting, if you create a user named blah the actual name of the user in mysql is often unixusername_blah. This is done automatically to prevent MySQL user name conflicts between different cPanel accounts sharing the same MySQL server.
With MySQL you can define which hosts a user is allowed to connect from. Is the new user you defined allowed to connect from your IP?
ETA:
Might want to have a look at the permissions for that user account and make sure appropriate permissions are granted. You can do this by running the following in phpMyAdmin or at the console:
SHOW GRANTS FOR 'something_root'#'localhost'
And compare the grants you see there to what you get here:
SHOW GRANTS FOR 'something_root'#'%'
Finally, depending on your hosting environment you may not have permissions to create new users or expand their privileges enough to be able to do this. This would be particularly likely if you have a shared hosting account.
How can I find out if my webhosting service allows remote connections?
It's better ask your whebhosting proveder, some allows remote connections, other no.
If they allow remote connections you may have to configure which hosts a user is allowed to connect from or, add a wildcard % to allow connections from any host.
Check if your hosting service allows connecting to its database server from outside its network.
Some hosting companies like GoDaddy, by default, don't allow this.
Also, you need to create a database user and assign permissions to it, through your preferred database administration tool.
reset mysql user password and then try again
http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html
I have built a web application which uses two web front end servers, the Users are randomly directed to either one through the same URL. The web app has specific functionality to upload and download files. When a file is uploaded, it is stored on a specific directory on the server to which it is uploaded.
The issue is that when a User uploads a file to the folder on Server 1, any user trying to download that same file from Server 2 will not be able to as it only exists on the server where it was uploaded.
What's the best way of solving this? I've looking at:
- Using a SAN, problem here is I don't want to change or create a domain
- Writing a Windows Service, would prefer to avoid this if possible, I've not done it before but will give it a go if necessary
Thanks in advance!
Joe
Unless I'm missing something very obvious, all you need is a shared location. This could be a network share addressed through a UNC path, a folder on an FTP server, a database, anything at all, as long as it's
shared,
accessible from both web-servers
web-application service account has read/write permissions to it.
From your requirements a network share on a file server (perhaps 1 of the 2 web-servers, or the load-balancer, or (ideally) a new server entirely) would be the simplest method.
As the title says, I need to access files from a server remotely. After doing this, I need to show the files in a windows file/folder Dialog style.
I need this using Remoting.
It's not that simple since I have some problems:
I don't have access to the client UNC sharing;
I don't know where the \server\xpto is physically pointed;
The service at the server must use the physical path.
Also, the sharing must be enabled (not always is), I'd need to prompt username/password and I'd have the network path, not the physical.
So, it's like accessing a server in a data center using the client app.
I guess you can do it by a web application. Create a page on the server which can reach the local files on the server and displays a list of them on a grid. You can add some commands on the files as well. The page you created would act as a middleware to reflect the operations you want on the files.
hope it helps.
I'm developing a C# application that needs to connect to a file share (using a service-level account) to download images.
The problem I'm encountering is that the users already have a set of credentials on that share's server that they use for other shares. It's like if you have a share mapped to a drive, you can't log into another share on the same server with different credentials. So when I try and log on with separate credentials for this app's share, I get:
"error 1219: Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again."
The code I'm using to try and connect to the share from this example, it uses the WNetUseConnection function.
Any ideas? Thanks.
edit: I've found a workaround for this, I just connect with the host IP address instead of the host name.
Make sure you are disconnecting the user once they are done, otherwise it is crowding the server and it can't allow same user anymore. Restart the server and close all connection after each usage.