SQL Server (Linked Server) - sql

My database is from a linked server and I have a problem with my connection string in ASP.NET (web.config) it says that :
Database schema could not be retrieved for this connection. Please make sure the connection settings are correct and that the database is online. Cannot open database "AA" requested by the login. The login failed. Login failed for user 'sa' at DataObjectSupport(423,6)
I try to use this connection string.
<connectionStrings>
<add name="localconnection" connectionString="Data Source=SERVERNAME;Persist Security Info=True;Initial Catalog=database; uid=sa; Password=password; " providerName="System.Data.SqlClient"/>
</connectionStrings>

Related

Unable to login with user that I created in sql database

I'm trying to connect with my DB using a account that I created with db_owner rights. Windows authentication works but not sql server authentication
I can confirm that the role was created as there is a error message login failed for user when using a wrong password. Compared to when correct password.
My local db is created in ASP.net web application by simply adding a local db in App data.
Error message is
user guest does not have permission to run DBCC checkpriamry file.
User has been created using
CREATE LOGIN [SomeUser] WITH PASSWORD = 'topsecret';
CREATE USER [SomeUser] FOR LOGIN [SomeUser];
exec sp_addrolemember 'db_owner', 'SomeUser'
EDIT:
<connectionStrings>
<add name="Shop" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Shop.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
https://imgur.com/a/9aCWVCU
are the links of error message
Your connection string when define login must be like this :
<connectionStrings>
<add name="Shop" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Shop.mdf;Initial Catalog=Shop.mdf;Persist Security Info=True; User ID=SomeUser; Password=topsecret;"
providerName="System.Data.SqlClient" />
</connectionStrings>

How to access a server system's local db from another system?(case:server-client scenario)

we used this connection string in client system where "Data Source=.*.**.57" is of server ip address and made the changes in the sql server configuration manager in server system accordingly.(i.e: TCP/IP protocol enabled)
<connectionStrings>
<add name="ConString"
connectionString="Data Source=**<ip address>,1433\SQLEXPRESS;Initial Catalog=HYD_TM;User ID=**;Password=**;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
Its always easier to debug connection string problems from an interface that is interactive such as Excel or sql management studio. In excel you can try to import a table from the data tab. If you succeed you can inspect the connection string and use it in your app.

Failed login for user

I'm developing a website for sharepoint using asp.net, it is connected to a database. In visual studio server explorer, the database is accessible using a new sql user I created. I granted sysadmin permissions to that user. However, when I deploy the site and run it, it gives me this error 'login failed for user'.
The sql server is configured to allow mixed authentications. I restarted the server, I played with the user permissions but nothing ever changed.
The connection string I got it from server explorer which I'm sure it is correct:
Data Source=servertest;Initial Catalog=qDB;User ID=me2;Password=***********"
What should I do? I've tried every possible solution I found on google and I ended up here.
Try like this by editing your connection string:-
Server=myServerAddress;Database=myDataBase;User Id=myUsername; Password=myPassword;
I too had same scenario this worked for me
<connectionStrings>
<add name="connectionstring" connectionString="Data Source=XYZ\SHAREPOINT;Initial Catalog=DBName;Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
You can Use connection string like this
<appSettings>
<add key="KhadamatConnectionString"
value="Server=[copy name from Your ServerName of SSMS];Database=AcaService;uid=admin;pwd=mypass;" />
</appSettings>
or
<connectionStrings>
<add name="KhadamatConnectionString" connectionString="Data Source=[copy name from Your ServerName of SSMS];Initial Catalog=AcaService;User ID=admin;Password=mypass;" providerName="System.Data.SqlClient"/>
</connectionStrings>

Can't connect to database when database has user and password

I am developing mvc 4 projects and when I use the following connection string it works:
<add name="name"
connectionString="Server=.\sqlexpress;Database=dbname;
Trusted_Connection=true;"
providerName="System.Data.SqlClient"/>
But when I add a username and password to this project, I can't connect to my database. I added the user credentials correctly. I have db_owner permission for this database, and in my database everything is correct. The connection string below does not work:
<add name="DocContext"
connectionString="Server=.\sqlexpress;Database=DocContext;
User ID=pooria;Password=19216801;Trusted_Connection=false;"
providerName="System.Data.SqlClient"/>
Connection String You are using follows format -
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
User ID=myDomain\myUsername;Password=myPassword;
Try using IP Address, Port in Data Source field like -
<connectionStrings>
<add name="ConnectionStringName"
providerName="System.Data.SqlClient"
connectionString="Data Source=190.190.200.100,1433;
Initial Catalog=MyDatabaseName;
Integrated Security=False;
User ID=MyUserID;Password=MyPassword;
MultipleActiveResultSets=True" />
</connectionStrings>
And the following link may help you
LINK

sql server connection string

I just deployed my database to my remote server. I am trying to create a connectionstring to the remote server and it won't work. I am using godaddy. I kept having this message: could not establish a connection to the database. Here is the connectionstring for the local server:
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
Can someone help me with the connection for the remote server? Lets say my database name is collins and my password is database, and the remote hosting server=quiz.db.4423045.hostedresource.com;
Given those connection elements you mention, your connection string ought to look something like this:
<add name="RemoteConnectionString"
connectionString="server=quiz.db.4423045.hostedresource.com;database=collins;
user id=?????;password=database;"
providerName="System.Data.SqlClient" />
What you're missing is a user name for the connection to the database (or you didn't specify one) - you need to place that into the connection string as value for the user id= attribute.
For a great listing and explanations of all things about connection strings, you should definitely check out http://www.connectionstrings.com
First I would check that you can access ports TCP 1433 and UDP 1434 on that server (you need also the UDP port since you are using the SQLEXPRESS instance in the server).
You can check that using nmap/ZenMap (Download) or any other port scanner. The ports should be reported as open.