Use different database in to different server connection getting error - sql-server

My code
:Connect DBSERVER -- Server name
USE SanjeevStockissue-- Database name
go
SELECT * FROM procduction WHERE Date='2022-8-30'
I am getting error
Connecting to DBSERVER... Fatal scripting error. Cannot open
connection specified in the SQLCMD script. Login failed. The login is
from an untrusted domain and cannot be used with Windows
authentication.

Related

ASP.Net MVC connections trying to remote SQL Server, unexpectedly creating a table

I am using the following connection string to connect to a SQL Server database
Data Source=ip,1433;Initial Catalog=mydb;User ID=dev_user;Password=testPassword
But instead of connecting, I am getting the following error
System.Data.SqlClient.SqlException: 'CREATE TABLE permission denied in database 'mydb'.
Installing Hangfire SQL objects...
Database schema [HangFire] already exists'
Why is it creating a database instead of connecting to SQL Server?
I have tried setting with Integrated Security to either true or SSPI, but I'm getting this error:
The target principal name is incorrect. Cannot generate SSPI contex" error instead
What am I missing?

Bad T-SQL code for account creation

How do I create a User using SQL code to join an SQL Server via SQL Server authentication mode. I used the code
CREATE LOGIN ANNACASSAR
WITH PASSWORD = '';
GO
CREATE USER ANNACASSAR FOR LOGIN ANNACASSAR;
GO
But I get this error:
Cannot connect to moscow\SQLSERVERMSWDEV.
Additional information:
login failed for user ANNACASSAR
(Microsoft SQL Server error 18456)
Set your server to Mixed authentication mode (right-click on the server in SSMS, Properties, Security, SQL Server and Windows Authentication mode, then restart the server).
However, you really should set a password, because it's a real security risk to create a login without a password.

SSH tunnel doesn't work in DataGrip

I have an Oracle database that is located on server_c and are only accessible if you are on server_b. So in order to connect to this Oracle database, I have to first log in to server_b via SSH, and type in the following command to connect to it.
sqlplus username/password#server_c:1571/service
I would like to connect to the Oracle database in DataGrip, first I typed in my username and password in the SSH/SSL tab.
Then I typed in the general database information.
I thought it would be fine, but when I clicked on the Test Connection, I got an error.
Error: Connection to Oracle - #server_c failed. ORA-00604: error occurred at recursive SQL level 1 ORA-20001: Server is not in the List of Valid Application Servers ORA-06512: at line 28
This error occurs if I try to connect to the database directly without logging in to server_b beforehand. In other words, I think DataGrip doesn't connect to the SSH tunnel first before connecting the database.
I'm not sure if I'm using SSH/SSL tab correctly in this way. So if you have any idea why it doesn't work or any solution to it, please let me know.
The clue is in the error message:
Error: Connection to Oracle - #server_c failed. ORA-00604: error
occurred at recursive SQL level 1 ORA-20001: Server is not in the
List of Valid Application Servers ORA-06512: at line 28
Check with your DBA either of:
a sqlnet.ora valid node checking tcp.validnode_checking = ...
or more likely:
a login trigger that prevents "unknown servers" from logging in.

Cannot open database "DatabaseName" requested by the login. The Login failed. Login failed for user

Here is the scenario.I'm creating a desktop application with VB.NET (Windows Forms), and using SQL Server 2008 R2 for its database.
I have two computers (PC1 and PC2) and I want to connect PC2 to PC1.
PC 1 has the SQL Server database. What I do is I just copied .exe application in
the debug folder of my vb project and create a notepad for its connection and put them into one folder and transferred it to PC2.
When I run my application to other PC, I get an error
Unhandled exception has occurred in your application. If you click
Continue, the application will ignore this error and attempt to
continue, If you click quit, The application will close immediately.
Cannot open database "DatabaseName" requested by the login. The Login
failed. Login failed for user
My code inside the notepad
Data Source=.;Initial Catalog=DBSAS;Integrated Security=True
What I have done so far is to enable remote connection of SQL Server 2008 R2.
Can someone please give me an advice about this? I am really confused. Thanks
Hi please find sql server instance name at PC 1 using below command
OSQL -L
replace . to the instance name at you connection string.
Specify Data Source= "sql server instance name " in the connection string.
more detail are posted on below link.
How can I determine installed SQL Server instances and their versions?.
On the second pc create a txt file on desktop. Something like test.txt. Then rename it to test.udl Universal Data Link. Double click the test.udl. From there you can produce a valid connection string to the SQL Server. After you are done open the udl file with notepad to get the connection string. Hope this helps.
Specify Data Source=PC1 in the connection string. The . indicates a local SQL Server instance running on the same machine as the application. The error suggests SQL Server is installed on PC2 but doesn't contain the desired database.
EDIT:
The error
Cannot open database "DatabaseName" requested by the login
indicates authentication was successful to the SQL Server but the database context could not be set. If DatabaseName in the error message is the same one as the Initial Catalog in the connection string, then either the database does not exist or the user does not have permissions to use it. However, if the DatabaseName in the error message differs from the connection string, the connection string you changed is not the same one that is actually being used by the application.

SQL server 2008 login issue

Hi I created a new login SQL server authentication in SQL server 2008, however I am unable to login with that user.
Getting an error like ,
TITLE: Connect to Server
Cannot connect to (local).
ADDITIONAL INFORMATION:
Login failed for user 'sa'. (Microsoft SQL Server, Error: 18456)
The error Login failed for user 'sa' means that connection to server was established, but server refused it under certain circumstances, such as:
Wrong password
Sql server uses only Windows Authentication (needs server restart)
In your Connection String you ask to connect to specified DB, which is not exists
sa login is Disabled or Denied to access sql engine
User Action
If you are trying to connect using SQL Server Authentication, verify
that SQL Server is configured in Mixed Authentication Mode.
If you are trying to connect using SQL Server Authentication, verify
that SQL Server login exists and that you have spelled it properly.
If you are trying to connect using Windows Authentication, verify
that you are properly logged into the correct domain.
If your error indicates state 1, contact your SQL Server
administrator.
From this article
Should this not help try troubleshooting this issue following these steps.

Resources