Choosing the right SQL database connection method - sql

I have a Windows POS application with remote SQL database.
What is the best way to connect my application to database ?
I'm thinking of connecting with one of these methods
port foreword ( currently using this methods. but it fails to connect sometimes, then I have to restart SQL server to get it connected again or wait for long )
VPN access
Install local SQL server and use replication to main server ( but I cannot lock database from unauthorized access as SQL local server and POS application running on the same system )
Please suggest me an option or if there any better option
Any help would be highly appreciated

Related

SQL Server Browser - Startup Type - Best Practice

During the installation of SQL Server Express 2012 on a new machine, I am able to specify the startup type of both the SQL Server Database Engine and the SQL Server Browser.
By default, the SQL Server Database Engine has a Startup Type specified as Automatic.
SQL Server Browser has a default Startup Type of Disabled.
After reading about what function SQL Server Browser serves, it would seem that it is something you would want to have running all the time, since it essentially keeps tabs on the various DB instances, and seems like it would speed up development for example.
What are the pros and cons to setting the Startup Type of the SQL Server Browser to Automatic for example? Or to get any use, would you need to set it to Manual and then specify it launch at startup?
Thanks.
From my experience (after making direct access to SQL Server) SQL Server Browser useful if you have Named instances and\or nonstandard(standard is 1433)\dynamic TCP ports.
SQL Server Browser actually listens on UDP port 1434 (default, should be open in firewall) and returns Server\Instance name to IP address\port. If you want to connect from remote client to some MyServer\MSSQL2008 or get available in your network SQL Server Browser will return list of "Instance name\IP address\Port" to your client.

How to connect to sql server database via LAN

want to connect to a database on another PC connected via LAN. I am able to use the sql server db with string like C:\Users... but i cannot connect using string like (\\Server\c\user...) I tried to move the db file to My Documents, still i get this error.
I get the following error message: An attempt to attach an auto-names database for file (\\SERVER\Users\Jeswills\Documents\TBSDB.mdf) failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share
I hope i asked the question correctly
As database does not support the '\SERVER\c...' parameters, i had to attach the database, after enabling TCP/IP and SQL Browser, i had to create a login through security and add it to the attached database file because authentication must be SQL not windows. And i also gave read/write privileges to the account. Then on the child system, i confirmed connection to the account through SSMS with the login connecting to SERVER (which is the remote computer's name).
Note: you must be able to ping the remote systems and SQL Server Express R2 installed. I tried with SQL Server Express but did not get a head way. www.connectionstrings.com/sql-server-2008 for more connection string
Then i used this connection string to connect remotely, making integrated security and user instance = false unlike if i were connecting locally.
Data Source=SERVER\SQLEXPRESS,1433;Database=DATABASEFILE.MDF;Integrated Security=False;Network Library=dbmssocn;Connect Timeout=30;User Instance=False;user='USERNAME';password='PASSWORD'
Not sure what specifically you’re trying to do here but I guess it’s one of these two.
Option 1
Attach database stored on remote shared drive to a local SQL Server
Note that this is only possible starting in SQL Server 2008 R2. If you’re running SQL Server 2008 this is not an option.
Check this for more details
http://blogs.msdn.com/b/varund/archive/2010/09/02/create-a-sql-server-database-on-a-network-shared-drive.aspx
Option 2
Connect to remote SQL Server instance from local computer
If that database is already attached to SQL Server instance that runs on the same machine then it’s much better to just connect to that instance from SSMS than trying to attach database from remote storage.
To do this you need to enable TCP/IP protocol in SQL Server Configuration Manager. It’s under SQL Server Network configuration node. Make sure you enable TCP/IP and also set enable the IP address for listening (this is under TCP/IP properties).
Apart from this you’ll want to enable remote connections on your remote instance. This is done from SSMS -> instance properties -> Connection tab
When this is done you should be able to connect to remote instance from local SSMS by typing in IPaddress/instance name. For example 192.168.0.125/{instance_name} or only IP address if this is default instance.

Connect to SQL Server from another computer

I have my websites database server named razatube.com, I don't have the server on my machine. How can I connect to this server from another machine to fetch database items? Any help would be highly appreciated.
PS: I don't usually use Microsoft products so pardon me if the answer stares directly on my face :(
All you need is the IP address or URL of the database server along with port number, login name and password of the SQL Server database. When you have all these, you can go to http://www.connectionstrings.com/ and get your desired connection string and use it into your web programs to connect your web server and your database server.

Failed to connect to sql data base on remote pc on network

I had windows application installed on pc on network and connect to sql database on other pc I had my connection string well but error apeared that I cannot connect to database
As the guys have already said, this is highly likely to be a firewall or other networking issue, but if you have checked that all through then the following might help.
1) Open up SQL Server Configuration Manager
2) Look in the tree on the left and expand SQL Server Network Configuration
3) Highlight the SQL Server you are looking for (I have SQL Express And SQL Server)
4) On the Right Hand side you will see a list of installed protocols and whether or not they are enabled.
From there enable the protocol you are looking to use.

How to connect to a remote SQL Server using servername, username & password

How to connect to a remote SQL Server using servername, username & password in SQL Server 2005 ?
I'm going to assume that you're talking exactly about what your question asks, how to connect to a remote MSSQL instance inside SQL Server, rather than through SQL Server Management Studio because 1) you don't mention SSMS and 2) it's pretty obvious how to connect with SSMS (I mean, the connect box is right there when you start it).
To connect to one MSSQL instance from another you can use linked servers. You can query data from linked servers, and if they are configured for RPC Out you can also execute SQL against them.
If the server is configured for integrated security, there is no way of doing it without changing the security option.
Check out the ConnectionStrings website - it shows you how to build a connection string that will allow you to connect from your machine to a remote SQL Server instance.
That connection string will typically look something like:
server=YourServerHere;database=YourDatabase;User ID=YourUser;Password=Top$ecret
But there are lots of options and additional things you can specify - the ConnectionStrings.com web site shows and explains them all!