Sql connection string issue

Solarion

Honorary Master
Joined
Nov 14, 2012
Messages
17,421
#1
I'm getting this strange error all of a sudden. It's the same across all my previously developed applications.

My connection string reads as such

Code:
  <connectionStrings>
    <add name="dbContext" connectionString="Data Source=DESKTOP-OBLIVION;Initial Catalog=StockTracker;Integrated Security=True;User ID=sa;Password=Qwerty12" providerName="System.Data.SqlClient"/>
  </connectionStrings>
However any connections I try and open to the DB crash because the local account that I log in with keeps getting appended onto the end database name as such.

Code:
DESKTOP-OBLIVION\\MyHomeMachine
I've never seen this before. Perhaps some kind of update did this? It is somehow tying my SQL in with my local account I think. No idea. Any thoughts?
 

Ho3n3r

Honorary Master
Joined
Apr 5, 2012
Messages
16,730
#2
I'm getting this strange error all of a sudden. It's the same across all my previously developed applications.

My connection string reads as such

Code:
  <connectionStrings>
    <add name="dbContext" connectionString="Data Source=DESKTOP-OBLIVION;Initial Catalog=StockTracker;Integrated Security=True;User ID=sa;Password=Qwerty12" providerName="System.Data.SqlClient"/>
  </connectionStrings>
However any connections I try and open to the DB crash because the local account that I log in with keeps getting appended onto the end database name as such.

Code:
DESKTOP-OBLIVION\\MyHomeMachine
I've never seen this before. Perhaps some kind of update did this? It is somehow tying my SQL in with my local account I think. No idea. Any thoughts?
DESKTOP-OBLIVION is the server(machine name), MyHomeMachine is the server instance - you need to connect to it if it exists. The actual database is StockTracer.

Edit your connection string to:

<connectionStrings>
<add name="dbContext" connectionString="Data Source=DESKTOP-OBLIVION\MyHomeMachine;Initial Catalog=StockTracker;Integrated Security=True;User ID=sa;Password=Qwerty12" providerName="System.Data.SqlClient"/>
</connectionStrings>
EDIT: I read too fast and misunderstood. Ignore the above. If you never had an instance before, that is odd that it adds it without you adding it in the config.
 
Last edited:

Solarion

Honorary Master
Joined
Nov 14, 2012
Messages
17,421
#3
Think I'm just going to re-install SQL Server. Just a really odd thing to start having and all my C# apps are crashing because of it. Weirdness galore!
 

CamiKaze

Honorary Master
Joined
May 19, 2010
Messages
11,960
#5
Just do a quick test for me please. Since you already have integrated security checked, can you remove "User ID" and "Password".


<connectionStrings>
<add name="dbContext" connectionString="Data Source=DESKTOP-OBLIVION\MyHomeMachine;Initial Catalog=StockTracker;Integrated Security=True providerName="System.Data.SqlClient"/>
</connectionStrings>
 
Last edited:
Joined
Jul 16, 2018
Messages
54
#6
So DESKTOP-OBLIVION\ is your computer name, and previously you were connecting to a default instance of SQL Server. Quite an old version yes? Did you just install a new version? The old instance is gone, so you either upgraded the old server, or deleted it and installed a completely fresh new one?

I don't think your new SQL instance is really called MyHomeMachine? I'm guessing it's called SQLEXpress? If you're connecting from the same machine, you don't need DESKTOP-OBLIVION\ either, you only need that if you're connecting from another machine on the same LAN.

Open up computer management, expand services and applications, expand SQL server configuration manager, click on SQL server services, and look what shows in brackets after 'SQL Server'. Here my server is called SQL2016.

1543915214296.png
 

Solarion

Honorary Master
Joined
Nov 14, 2012
Messages
17,421
#7
I think the issue started when I re-imaged my drive. This rolled back my version of visual studio and SQL Server to 2014. Somewhere along the line between my local account and SQL something has like unsynched? I'll try this when I get back this afternoon Potty thanks!
 

Nerfherder

Honorary Master
Joined
Apr 21, 2008
Messages
23,921
#9
I think the issue started when I re-imaged my drive. This rolled back my version of visual studio and SQL Server to 2014. Somewhere along the line between my local account and SQL something has like unsynched? I'll try this when I get back this afternoon Potty thanks!
That makes sense.

in your logs it will tell you what user it is using. Give that user the right access. Integrated security means you are logging in with the user that is running the process.

Also read this :

https://stackoverflow.com/questions...tegrated-security-true-and-integrated-securit

you should be using
Code:
Integrated secuirty=sspi
 
Joined
Jul 16, 2018
Messages
54
#10
SSPI used to matter back in the days of OleDb, but the OP is using native client.

Setting Integrated security to either SSPI or True will make your app attempt to log into SQL server using windows authentication, even if you include an SQL authentication username and password in your string. If you don't set Integrated security, or set it to false, it will attempt to log into SQL server using SQL authentication, it will then require the username and password.
 

Solarion

Honorary Master
Joined
Nov 14, 2012
Messages
17,421
#11
If this was a production environment rollback I'd be in a real jam. Probably better that I learn about this type of issue now. The only hang up atm is that I'm unable to load any of my projects at home but at least it's not an emergency. Will sit down with this in a bit this evening after dinner.
 
Joined
Dec 15, 2016
Messages
9
#12
I am not sure I am junior but isn't integrated security windows login and you cannot use it with a username and password combination because it will just try login with your windows account?
 

Solarion

Honorary Master
Joined
Nov 14, 2012
Messages
17,421
#13
So DESKTOP-OBLIVION\ is your computer name, and previously you were connecting to a default instance of SQL Server. Quite an old version yes? Did you just install a new version? The old instance is gone, so you either upgraded the old server, or deleted it and installed a completely fresh new one?

I don't think your new SQL instance is really called MyHomeMachine? I'm guessing it's called SQLEXpress? If you're connecting from the same machine, you don't need DESKTOP-OBLIVION\ either, you only need that if you're connecting from another machine on the same LAN.

Open up computer management, expand services and applications, expand SQL server configuration manager, click on SQL server services, and look what shows in brackets after 'SQL Server'. Here my server is called SQL2016.

View attachment 587088
I actually don't even have it running under Services and Applications. Going to do a full SQL re-install tired of fighting with it. Tried everything in this thread to no avail. Thinking Microshaft did some update and it messed with all the policies or something.

Edit: Crapsticks! When I refreshed the machine I had previously imaged, I had two accounts on there. One was my admin account the other one I created for a Dev environment. When I first logged in after the refresh I signed into the wrong account. I signed out and signed into the admin account, everything working perfectly :D
 
Last edited:
Joined
Aug 8, 2017
Messages
523
#15
I actually don't even have it running under Services and Applications. Going to do a full SQL re-install tired of fighting with it. Tried everything in this thread to no avail. Thinking Microshaft did some update and it messed with all the policies or something.

Edit: Crapsticks! When I refreshed the machine I had previously imaged, I had two accounts on there. One was my admin account the other one I created for a Dev environment. When I first logged in after the refresh I signed into the wrong account. I signed out and signed into the admin account, everything working perfectly :D

Release the Kraken!

On a serious note, it is always better to figure out that it was a user error and not just some ungodly windows bug. I find windows sqlserver users to be the real brave soldiers of the software industry. Would not be caught dead using sqlserver. :)
 

kripstoe

Expert Member
Joined
Sep 15, 2012
Messages
3,479
#17
On a serious note, it is always better to figure out that it was a user error and not just some ungodly windows bug. I find windows sqlserver users to be the real brave soldiers of the software industry. Would not be caught dead using sqlserver. :)
What in your opinion makes it so bad?
 
Top