I have hosted a web application(Application is in Asp.Net with C# language and Sql server database). Now i want to store data in my local database from my hosted web application.How will be the database connection string...any addition changes in Sql Server..?Please explain..Any reply will be appreciated..
DeEP
from .NET 2 upwards the connection string can be stored in a specific node of the web.config file and not in appSettings as it was done before.
I am not sure about your question because if you try to access a database server located outside the network where you have deployed your ASP.NET application (so the hosting provider's internal network), it won't probably work, even in case your SQL Server is publicly available and open for connections from outside (which is bad, really, really bad...), it would also depend on the hosting company network settings.
How did you connect to the SQL Server during development and for debugging within the development machine?
There are info on how to connect to a SQL Server with a connection string in the web.config here: Using connection strings from web.config in ASP.NET v2.0 but not sure this solves your issue.
Sounds like you need to speak to your network administrator - I'd guess that your firewall will probably be set up stop any attempt to access it from outside of your network.
If your hosting company allow it, you maybe able to set up a VPN between the web server and your local database but this would be a lot of hassle.
Related
I have some Databases built in Access and I want to be able to view and edit them when I'm not connected to a local server\network.
How can I access with C# to view and edit the Access databases placed on a server without VPN or SMB (which means creating local network). Is it possible to edit it realtime on the server?
This needs to be accessed by more than one people, thus I also want for example block a table if one's already editing it (so here also goes the FTP protocol - to download and edit on the PC and reupload)
I hope I was clear enough and provided enough info, thanks for all helpers!! Enlighten me please :)
We would first have to ask how end users going to run and use the C# program?
Desktop: users would need a network connection to the server. (most likly a VPN).
Web based: users would need a network connection to the WEB SERVER. This could also be a VPN, or could be a web server that is public facing. this would then require logons for security.
If users don't have a network connection, then it not going to matter if this is oracle, MySQL, SQL server or Access. And in fact, if this is web based, then users need to be able to connect to that web server.
So, without some kind of network connection to that server or computer where the data resides, and you eliminated a VPN, then your options are limited.
You can build a web site and place it on a server. However, if users don't have any kind of network connection even in the case of a web site, then I fail to see how you can even suggest using FTP let alone any other kind of connection.
This needs to be accessed by more than one people,
Ok, you need multi-user. However the locking up a whole table on sql server to allow only one user is actually quite difficult.
But, we can leave that you want one user in a given table at one time. (but both Access and a web site would in fact allow multiple users - even editing the same table).
All in all?
Then this suggests the most obvious solution: run a web server, and that would allow any user to connect to the web site, and the web site then can read/talk/use the access database that resides on that server. And this then again means that you don't need any client software installed.
FTP is not a practial solution - since it only works on a whole file.
So, users will require some means to connect to some server. That being the case, then write your C# appliation as web based, and thus no client software will be required, and the only software that interacts with the access file on that server will be the web site.
So, running a web site on that server does seem to be the best option.
So, we heading towards a web solution.
So then software would stay and run 100% on the server side, and thus zero client software would be required other then that of a browser.
I developed a simple Python web server to work with the Access DB via HTTP:
https://github.com/vikilpet/MS-Access-HTTP-Server
Probably this is not an ideal solution for your case but it may be a good starting point.
I am looking into using the new SQL Server Express LocalDB (I think it is code named "Denali") for a desktop application.
It is currently running with SQL Compact, but the user is wanting to share the database between multiple PCs on a network. Unfortunately this is not something that SQL Compact can do, so I am investigating other solutions.
The client requires the ability to send database files easily to other sites or to back them up to a flash disk, so I am avoiding going to SQL Express because there is quite a bit of "administrator" knowledge required to backup and restore.
So, my questions is, does the new SQL Express LocalDB support remote connections to the database over a network and/or through a shared network folder with the mdf file in it?
LocalDB does support supplying a path for an attached local DB in it's connect string (AttachDbFileName) hence the shared network folder option.
NOTE: This question pertains to "LocalDB" the new version of SQL Express 'Denali' and not to SQL Server Express 2008 or prior.
See article here announcing LocalDB's release: http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx
No, SQL Server Express LocalDB doesn't accept remote connections.
The idea with shared network folder might work, but only if you are able to make sure the LocalDB instance is shutdown before you try to copy the file. Also keep in mind that only one LocalDB instance can have any given database file open at the same time. and don't forget about the log files!
Additional security warning: unlike SQL Server Compact databases, SQL Server Express databases (including LocalDB ones) are not designed as secure data exchange format. For instance, they can contain malicious code in .NET assemblies embedded in them. So you should never open databases from untrusted source.
Maybe providing the customer with a simple tool that automates the backup process would be a better idea?
This isn't a fresh thread, but I would like to share my experience with SQL Server Express database LocalDB.
I have a WPF C# project using SQL database with LocalDb Engine. It is working fine no problem, I can use the database with the WPF app. I wanted this app to work on network with more PCs.
On the network another PC can use the database from my PC using UNC path in the connection string.
It seemed to me the remote connection is working. However when the remote PC is connected, I am not able to use the database with my local WPF app. If I run my app first the remote PC could not connect. So this tells me that the remote connection is working, but the multiple connection is not allowed.
OK, I didn't give up and I run the app from my PC twice and I saw it is working which tells me that the same SQL LocalDB engine can handle multiple connections locally only.
I hope this experience will help someone. Thanks.
In short, yes it can. Here is a tutorial on how to configure it.
Also, here is another post with a potential issue that might occur.
Both explain how to configure SQL Server Express to accept Remote Connections.
I have a bunch of small desktop applications for which I have a simple database for keeping user data (who uses which app and in which version) etc.
I want the apps to connect to Azure SQL server and update database record when they're started. My apps have the ADO.NET connection string hardcoded in them.
It works fine from my home network and my company guest network - however, the corporate network has got some of the ports disabled, and that apparently includes port 1433. As per Microsoft troubleshooting guide, I tried telnet and failed.
C:\Users\xxx>telnet 65.55.74.144 1433
Connecting To 65.55.74.144...Could not open connection to the host, on port 143
: Connect failed
I cannot connect neither via my applications, nor by SQL Server explorer in Visual Studio.
So, the question is - how can I get around this problem? It is highly doubtful that corporate IT will unlock a port just because I ask, besides I want to keep it as simple, low profile and independent as possible. Or maybe my approach is incorrect from the very beginning and I should do stuff differently?
Cheers
Bartek
You can't.
Make your desktop applications talk to web services instead, over HTTP/HTTPS. Among other things this will also allow a more controlled access (right now anyone can connect to your database and modify the data, since your access credentials are publicly shared with your app).
A side effect of using we services is that 80/443 are almost always opened in all corp firewalls.
We have a requirement (I believe as part of a post build/deployment verification test (BVT)) to test that remote server A can "connect" to remote server B.
I want to develop a console application using C# on my LOCAL developer VM. This should then "connect" to remote server A. It then needs to check that remote server A can "connect" to remote server B (via the original connection from LOCAL to remote server A).
Currently I have generated a simple "helper" exe that connects to remote server B (using a prior known connection string point to remote server B and SqlConnection classes). The exe is copied to remote server A as part of the build process (at the end). PSEXEC.exe on the build server then remotely starts the "helper" exe on remote server A and checks the %errorcode%. This then determines if the BVT should pass or fail (Then the "helper" exe is then deleted from remote server A).
FYI all machines run Windows Server 2008 R2 x64 Enterprise and are on the same local domain. I am an administrator on all 3 machines.
Remote server A is a web server and remote server B is a SQL database server. The LOCAL machine will/does represent the build server. This test is simple as saying "can the web server connect to the database server". The difficulty is how to do that remotely.
I know I can just do System/integration/end-to-end testing (using Coded UI etc) and we are doing this but want to consider this requirement/test as well (as the servers and network configuration etc are a "shared responsibility" with an external party and we cant guarantee that anything has/will change without our knowledge (other than reacting via Service Desk processes))
The process I have adopted seems OTT but does appear to work (if I close ports etc). Is there a completely .NET way of doing it using TCPCLient classess or something etc? What about doing webservices and hosting them on the webserver and call them from the build server? Other ideas and things to consider more than welcome.
Why not create a test page on the web server that carries out an innocuous operation against the SQL server.
The page might execute a simple query (select top(1) name from person) for example.
I can see web-services tagged in your question. If you want to verify connectivity to a server hosting web services or between a server hosting web services and an underlying back-end server (database for example), the best way to be sure (in my opinion) would be to call an innocuous service that does a simple read. Retrieving WSDLs would not be enough.
You can use Management objects to query and control computers and servers on your domain.
http://msdn.microsoft.com/en-us/library/system.management.aspx
SQL server includes some extra objects specific to managing SQL Server.
http://msdn.microsoft.com/en-us/library/ms220749.aspx
If you have Linqpad:
ManagedComputer mc = new ManagedComputer( "yourserver" );
mc.Dump();
otherwise create a console app and create an instance of ManagedComputer and use the debugger to query the computer's SQL server, to see the sort of information available.
As you can see its a big subject...
I am working on windows forms application using c#.net. i have developed an application(3-tier) that uses sql database as backend. i need to deploy the database on server and my app. on client machine. but how could my application communicate with database on server. please guide me.
you need a connection string that works fine during development. On your development machine if the application is connecting fine to the database server, chances are that on your client machine, it would work as well. Sometimes, the problem occurs with the credentials that you use, that might work on the development machine but on the client it wont connect due to the lack of access rights. so you need to make sure that you give proper credentials to connect to the SQL server
You don't need to do any rocket science for this. All you need to do is on the client side use the proper connection string that can connect to a remotely installed SQL Server.
Use EntityFramework for your sql server connection for updating, inserting and deleting.
Use storedprocedures for the insert/update/delete functions.