• CONTEST ALERT - Experience the power of DDR5 memory with Kingston Click for details

Remote SQL Server to be used in Stand Alone Application

Not open for further replies.


The Thunderer
Geeks! I am trying to develop a Stand Alone Employee System. It works perfectly when the SQL DB is in same system with the Front End, but what I am looking forward is to keep my SQL DB is Local Network Server and Front End to be on terminal PC.

I used this code to access the DB when SQL and Front End is in same system.
Shared cs As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=" & Application.StartupPath.Replace("\bin\Debug", "") & "\hrims.mdf;Integrated Security=True;User Instance=True")

Please help me what code to use if I want my SQL DB "hrims.mdf" to be in SERVER.



The Mighty Unkel!!!
Staff member
why two threads? :S

you need to check some basics before you can connect to the remote sql server, cause out of the box (default settings) SQL Server does not allow remote connections. you need to enable it.
please look into the basics of using "Connection Strings" WRT SQLConnection Object
also you should not be attaching the DB file if you want to access the file from remote source.
replicate the DB structure in the remote server. the use the following syntax,

1. Setup SQL Server in remote machine.
2. Enable SQL Authentication
3. Enable Remote connections - important else you wont be able to connect to this SQL Server instance.
4. create correct connection string to which points to the Remote SQL Server.
5. use the connection string in your app to connect to the remote server

Data Source=SERVERNAME\SQLExpress;Initial Catalog=YourDB;User Id=Username;Password=Password;
note: the username and password is SQL Authentication.

Use this Reference
How to configure SQL Server 2005 to allow remote connections


Simply a DIGITian
Staff member
No need to create duplicate threads for same purpose.

What you are doing is wrong. I mentioned the Connection Strings on older thread. Refer that.
Not open for further replies.
Top Bottom