DIGIT-ARC read-only archive · snapshot: July 23, 2026

Remote SQL Server to be used in Stand Alone Application

3 posts · originally from https://geek.digit.in/community/threads/remote-sql-server-to-be-used-in-stand-alone-application.163183/

bhutanesedude
bhutanesedude Original post #1
Sep 12, 2012 at 12:09 PM
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.

Regards
RCuber
RCuber #2
Sep 12, 2012 at 1:07 PM
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
krishnandu.sarkar
Sep 12, 2012 at 9:04 PM
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.