user3701907
user3701907

Reputation: 41

Access SQL Server database on another computer

I have created a little tool, which lets me write some data into a database.

This database is located on my laptop and as of until now, that tool was only able to locally access the database. I now need my friend to be able to use that tool to connect to my database from his own PC.

I've read about port-forwarding, opening the firewall, etc., but I've never really gotten the hang of it.

This is what I currently have:

SqlConnection myConnection = new SqlConnection("user id=admin;" + 
                                   "password=password;server=myDatabase;" + 
                                   "Trusted_Connection=yes;" + 
                                   "database=database; " + 
                                   "connection timeout=30");

And of course, the usual procedure:

try
{
    myConnection.Open();
    //Do Stuff
}
catch(Exception e)
{
    Console.WriteLine(e.ToString());
}

Note: I don't really care much about security, since the usage of this tool is only temporary and I doubt that anyone would try to "break in".

Upvotes: 1

Views: 234

Answers (1)

Alexei - check Codidact
Alexei - check Codidact

Reputation: 23078

Take a look upon activating Remote connections to your SQL Server Instance. As already mentioned, they will not work on Express editions, but since your project is temporary, you may install a trial (lasts for 180 days).

Upvotes: 1

Related Questions