I'm having trouble trying to get Visual Studio to connect to a database located on another server.
Here is my connection string :
<add name="CDDMSDB" connectionString="Database=CDDMS;Server=aecl-db01.domainx.local;Integrated Security=SSPI;Connection Timeout=7200"
providerName="System.Data.SqlClient" />
Now when I try to connect via my app, I get the following error :
Login failed for user 'DOMAINX\CDSDEV_NATHANIE$'.
The Account DOMAINX\CDSDEV_NATHANIE, does not exist. I am logged in under the account empower\nathanielp, but it does not seem to be using that account at all. I can connect to the SQL Server through Management Studio just fine using empower\nathanielp, but for whatever reason its not using that account when I run the app.
Any suggestions?
Thanks,
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring%28VS.71%29.aspx
According to this it is pulling your windows account credentials when you are trying to log into the database and that could explain the "The Account DOMAINX\CDSDEV_NATHANIE, does not exist." IF your windows account credentials doesn't exist on the server you are connecting too.
I would set Integrated Security=false and put the username and password you are logging into the server under in your connection string. using User ID= and Password= Hope this helps.
Related
I've tried to connect the SQL server from another machine(DummyUserOne) of the same domain(DUMMYDOMAIN) using the JDBC URL via Java Application.
JDBC URL
jdbc:sqlserver://:1433;databaseName=DummyDB;integratedSecurity=true;domain=DUMMYDOMAIN
Issue faced while trying to connect with SQL server : Login failed for user 'DUMMYDOMAIN\DomainUserOne$'. Reason : Could not find a login matching the name provided.
SQL Version : 15.0.2095.3
Resolution 1 : Added the User "DUMMYDOMAIN/DummyUserOne" in SQL server, but still same issue persists.
Resolution 2:
Later, found that service account is different from machine account and need to add the machine account as user.And it should added as "DUMMYDOMAIN/DummyUserOne$"
But the SQL server doesn't allow to "DUMMYDOMAIN/DummyUserOne$" as a user saying no such user found.
Tried creating via SQL Server Management Studio and also using the following query via sqlcmd
CREATE LOGIN [DUMMYDOMAIN\DummyUserOne$] FROM WINDOWS
Resolution 3:
Adding "NT AUTHORITY\NETWORK SERVICE" as user and giving required permissions.
All attempts failed with same issue.
My Questions are
Why there is '$' include in the username while trying to connect via JDBC url?
What is difference between the service account and machine account?
If "IntegratedSecurity=true" is used in connection URL, will take the service account or machine account?
Finally, How to add the machine account to the SQL server?
using sql server managment studio I can connect database using sever authentication with
login = sa , password = 1
But I cant connect using server explorer (and from web app) in visual studio.
<add name="DefaultConnection" connectionString="Server=localhost;Database=XXX.mdf;Integrated Security=False;User Id=sa;Password=1"
providerName="System.Data.SqlClient" />
login failed for user sa
Can somebody answer this strange behavior?
I have 64bit Enterprize edition. Thanks.
Database=XXX.mdf
Is your database actually called XXX.mdf? I suspect it isn't, since that looks like a file name, and is perhaps just called XXX instead. The login will fail if the database isn't correct, since the server isn't going to give information about the failure to an unauthenticated user. Try:
Database=XXX
I have SQL Server 2010 running in windows auth mode and the proper groups have been assigned. I can connect via the SQL Server Client Studio using windows auth. That works. But when connecting using .NET OLEDB connections it fails and I can't figure out why.
Here is the string:
data source=172.20.0.113;initial catalog=ForgeEnterprise;Integrated Security=SSPI;multipleactiveresultsets=True;App=EntityFramework
And here is the error:
Login failed for user 'MOMENTUMI\jmcclure'
Is there something I'm missing?
According to http://connectionstrings.com/sql-server-2008 this should do the trick
Provider=SQLNCLI10;Server=172.20.0.113;Database=ForgeEnterprise;Trusted_Connection=yes;
Where Trusted_Connection is the same as Integrated Security apparently.
If that doesn't work, you should verify that the user is added in the permissions tab (picture) for the database, but I guess you already did that.
first I have checked that Server Authentication is already set to:
"SQL server and Windows Authentication mode" (mixed mode)
้here 's my web.config connectionstring
<connectionStrings>
<add name="StockConnectionString" connectionString="Data Source=192.168.0.2;Initial Catalog=Stock;Persist Security Info=True;User ID=op;Password=operator" providerName="System.Data.SqlClient"/>
</connectionStrings>
Whene I test running (ctrl+F5) under VS2010 development this can connect to remote SQL server without any problem. but when i publish this project to local IIS (same web.config) an error occured..
Login failed for user 'op'. Reason:
Not associated with a trusted SQL
Server connection.
also i can connect to SQL server via SQL server Management Studio with SQL server authentication same user/pass.
no idea what's wrong with this.
finally, after 3 days can't figure this out. then i tried start over.
created a new project (ASP.NET MVC 2 web app) in VS2010.
go to Database Explorer > Add Connection..
use SQL server authentication to remote SQLserver directly instead of local.
then gotcha!! it told me..
this server version is not supported. you must have Microsoft SQL server 2005 or later.
my project was created under Win XP connect to SQLserver 2000 and it's work fine. now the answer for an error above is..
Visual Studio 2010 dropped support for SQL Server 2000. You'll either have to go back to VS2008/SL3, upgrade your SQL Server, or do things manually outside of Visual Studio.
...really appreciate this so much
Does it make any difference if you add this to the connection string ?
Trusted_Connection=False;
A clue is that it's saying that it's not trusted which indicates it's not using the username and password from the string. Has a connection string been possibly imported into IIS ?
Trusted is windows authentication which by the error is being used. Sql server authentication is username and password which you are trying to use.
It installed automatically with Visual Studio 2010 Ultimate. I didn't create any users for the server or ANYTHING.
I'm using:
string connectionString = #"Server=.\SQLEXPRESS;Database=SportsStore;Trusted_Connection=yes;";
I get error that authentication failed. So the server is being found, but my credentials are wrong. What would the default login and password be?
Edit: Still not working! :(
Here's my connection string:
string connectionString = #"Server=.\SQLEXPRESS;Database=SportsStore;Integrated Security=SSPI;";
And the error message:
Cannot open database "SportsStore"
requested by the login. The login
failed. Login failed for user
'ToshibaLaptop\Sergio'.
If you are using SQL Server authentication you could try the username sa and blank password but I am not sure whether this is by default. Integrated Windows authentication should work, so you should be able to connect with your Windows account:
string conn = "Data Source=.\SQLExpress;Initial Catalog=mydb;Integrated Security=SSPI;";
You probably should not connect using Sql Server Authentication.
Log in as an Administrator on the box, connect using Integrated Windows Authentication, and you should be a system admin.
The error message indicates that SQL Server can't open the database. I think you're successfully authenticating, but having a problem connecting to the database. Is the database available?
You can do a test by changing the database to master in your connection string. If that succeeds, then you're problem is related to the database. I understand that you may get other errors, but the test is to confirm that you can login to SQL Server.
For me SQL Server (SQLEXPRESS) service was disabled so it was throwing the error. After enabling the service SSMS is working fine
Goto Run command and type services.msc and click on OK button
Services window will open. Check the status of SQL Server (SQLEXPRESS) service
If the service is not running, then start the service
Now try logging in again in the SSMS.
In SQL 2008 if you use the defaults there won't be a SQL Server user only Windows Authentication will be enabled - and it will only work for the user that installed the application would have access via their Active Directory authentication.