How do I connect to a SQL 2019 instance, from another computer?

  • I'm working on an ASP.NET MVC app, following along a tutorial in CODE magazine. I'm doing this tutorial at home, with SQL Server 2019 Developer Edition installed on a Windows 10 Professional PC, named RazorCrest. I'm doing development on different Windows 10 Professional machine. Using the connection string from the article's tutorial, I've changed it to use RazorCrest, so it looks like this:

    "Server=RazorCrest;Database=PaulsAutoParts;Trusted_Connection=True;MultipleActiveResultSets=true"

    I'm doing this in a home environment, just peer-to-peer network.

    When I tried to just verify the connection from the app, which just does a SELECT from a table with only a few records in it. However, it failed with this error:

    Microsoft.Data.SqlClient.SqlException

    HResult=0x80131904

    Message=Failed to generate SSPI context.

    Source=Core Microsoft SqlClient Data Provider

    I've done this before with a different app, but in that case I used SQL Authentication instead of Windows authentication. In this case, the author of the tutorial is used Windows authentication. I had hoped I could use that, giving my Microsoft credentials when the attempt to open the connection came about, but as you can see by the error that didn't happen. I'm wondering, is it possible, given my peer-to-peer network, to make this work with Windows authentication? Or must I use SQL Authentication?

    Rod

  • Yes it's possible. You can see if this thread helps.

    For the purposes of the .Net tutorial, it seems like authentication type should be irrelevant.

  • Without a domain - you need to have local accounts on both systems with exactly the same username and password.  And even then - you can end up having issues connecting.

    Just change it to a SQL account - that shouldn't cause any issues with the tutorial.

    Also note: unless specifically required for your application, using MARS can cause performance and should not be used.  I don't know anything about this tutorial but my guess is that you really don't need multiple active resultsets.

    Jeffrey Williams
    Problems are opportunities brilliantly disguised as insurmountable obstacles.

    How to post questions to get better answers faster
    Managing Transaction Logs

  • I've been working on another tutorial for writing APIs using ASP.NET Core. That works, but in that case I used SQL Authentication. There's two reasons why I was going with Windows authentication:

    1. That's the way the guy who wrote the tutorial did it, so I figured I'd just follow suit.
    2. I set up the repo as a public repo on GitHub. I don't want to expose a SQL username and password in the source code, even if it is just on my personal Windows 10 Pro machine. I considered the possibility of exposing sensitive information in the C# code in my GitHub repo, but since the tutorial's code was using Windows Authentication, I thought it wouldn't be an issue.

     

    Rod

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply