Connecting to a local SQL Server database - sql-server

While making web.config, I tried to connect local SQL Server database with the web
<add key="DSN" value="server=localhost;uid=test_demo;pwd=1234;database=DB_PRE"/>
However using "DSN" with value server = localhost does not successfully connected to the local SQL Server database. And I'm not sure with creating uid and pwd I want to know how to use "DSN" to connect to the local.
I'm using SQL Server 2008, IIS Express 7.

So it was port number problem at first, designating the initial(base) port number for the Database server, and the password policy should be turn off.
Password policy required me to change password regularly after some amount of time, and this was the error which is really hard to find

Related

Cannot connect Access to SQL Server Linked Tables - error message loggingin

I have a client for which I am setting up a new SQL Server Express and (on a different computer) connecting their Access front end to that SQL Server. I created an account on SQL Server, changed authentication to SQL Server. I am able to log on to that account with no issues locally (through SQL Server Management Studio) on the server itself, but when I go back to the client machine and try to create either an ODBC connection or connect directly in Linked Table manager, I get the error below. Looking at the error log in SQL Server I can see no failed logins. In Access and/or ODBC I use Servername\SQLEXPRESS, choose SQL authentication and type in the username/password that I created. But it's still being stubborn.
I'm kind of at my wits end with this one. I checked to make sure that login is enabled, that the created database is mapped to this user, but I'm out of answers. Anyone have any ideas? I'm sure it's something really stupid that I'm overlooking, I've used SQL Server for a long time but I'm not an experienced DB Administrator I'm sure it's something really simple I'm overlooking, but I've done this hundreds of times before. And Windows Authentication won't work because it's on a different computer.
To connect to a named instance on SQL Server Express with Servername\SQLEXPRESS, you need:
SQL Server Browser service running,
and its UDP port 1434 open in the firewall.
https://learn.microsoft.com/en-us/sql/sql-server/install/configure-the-windows-firewall-to-allow-sql-server-access
SQL Server Browser service
UDP port 1434
The SQL Server Browser service listens for incoming connections to a named instance and provides the client the TCP port number that corresponds to that named instance.
The fixed TCP port for your instance open in the firewall.
You set this in SQL Server Configuration Manager
https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-a-server-to-listen-on-a-specific-tcp-port
This looks more like a network setting rather than server issue.
Check if all necessary permissions, configuration and settings on your machine running the server are OK to accept external connections.
Usually its the server that is rejecting the connection for security reasons.

How to restrict remote user to connect SQL Server Database except some of them using Kaspersky Endpoint Security 10?

I don't want anyone to connect SQL Server from another domain except some of them.
I tried to block the port of SQL server through Kaspersky on my database server. But it doesn't block

How to Connect to My Local Network SQL Server

My desktop machine has SQL Server installed. I can connect to it (using my desktop machine) using the following server name:
localhost\SQL_Express
Windows Authentication
If I want to connect to it using my Laptop, I try to do the following (ACER_ASPIRE is my computer name):
ACER_ASPIRE\SQL_Express
SQL Authentication (acerAspireUserName, acerAspirePassword)
I get an error saying the server wasn't found. How can I go about connecting to my desktop machine's SQL Server from my Laptop?
To connect to a Sql Server you need to specify two things.
1 - Server name
In this section you are suppose to provide [ServerName\InstanceName]
Server Name is the Machine Name where your sql server Instance lives. And obviously since sql server can have multiple instances on one machine you need to provide the instance name that you want to connect to.
There is an exception for Instance name if you are connecting to the Default Instance you dont need to provide full [ServerName\InstanceName] you can only use the machine name to connect to the default instance on sql server on that machine.
One thing you need to know is
localhost == . == MachineName == ServerName
These are all different ways you can tell sql server , the server name that you want to connect to.
2 - Authentication
You have two ways to authenticate yourself when connecting to sql server,
Windows Authentication.
Sql Server Authentication.
In 1st section ServerName you told sql server that which machine and what instance you want to connect to.
Now in this Authentication Section you will have to tell sql server how you will be Authenticated.
When using Windows Authentication Sql server will use your windows credentials to identify you. This has nothing to do with the Server/Machine name it is to do with the Operation system of the machine, in your case it is windows and you can use your windows credentials.
On the other hand if you use Sql Server Authentication you will have to use a Sql Server Login' andPassword`. In this case sql server will not care what operating system you have on your machine. (mostly used when you are working on operation systems other than windows like Linux, Unix, Mac). It will only take consideration the login and password you pass.
Authentication Mode
What Authentication Mode you can use? this depends on your sql server configuration when you were installing, You can set your sql server to Only Allow Windows Authentication or Mixed Mode (i.e Windows Authentication and Sql Server Authentication).
Your Case
In your Case regardless of what Authentication Mode you are using. You can use any notations in sql server SERVER Section as long as they point to your machine like
local, localhost, . , ACER_ASPIRE
But for Authentication if you are using Sql Server Authentication Make sure you are using a Valid Sql Server Login and Password.
Open the query window, and inside it execute the following:
EXEC sys.sp_configure N'remote access', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO
This option is not enabled by defauld on Express edition.
By default, SQL Express doesn't support LAN Connections, only from local machine.
To use it you must configure to listen to network ports also. You can do that on the SQL Server Surface configuration tool.

Connect to SQL Server database

I'm trying to connect to a SQL Server database at Discount asp.net hosting with SQL Server Management Studio. Here`s the connection string that is working fine. What parts of it should I use in Management Studio to connect to remote Db?
Data Source=tcp:sql2k803.discountasp.net;Initial Catalog=SQL2008_709539;
User ID=SQL2008_709539_user;Password=password;
I'm filling the fields in the following way:
Server name: tcp:sql2k803.discountasp.net
login: SQL2008_709539_user
password: password
authentication type is SQL Server.
If it returns "Login failed" then you are getting to SQL Server but SQL Server is rejecting you (so it won't involve firewall, DNS, etc). Did you try explicitly setting the database information in the Connection dialog in SSMS? You may have to follow up with the host and ask them what state was found in the SQL Server log to go along with your failed attempt to log in. This is often because the database wasn't specified or the wrong database was specified.
Here is a list of all the states I've observed and what they probably mean, if your host won't directly tell you what to fix but they do tell you what state was found in SQL Server's log:
Troubleshooting Error 18456
Database: SQL2008_709539
Login: SQL2008_709539_user
Password: password
Host: sql2k803.discountasp.net
Please note also:
Some hosting companies denies access by default so you may have to request access from your IP address
Sometime I was unable to connect using host name, I used IP address to connect via Management Studio (such problem appear due firewall, proxy, etc)
ADDED:
Also see whether you've enabled remote tcp/ip connections
If it's working fine, use tcp:sql2k803.discountasp.net as server address, and user / pass as login data

sql server 2008: configuration information

I have sql server 2008 installed on my dev machine. How I figure out things like, the name of the server, do I connect to it using windows auth or using sql auth. If I connect using sql auth what is my account information. I set it up a while back and I dont know how to read all the sql server install and configuration information. I am trying to install Vault and its trying to connect to sql server and I dont know things like sql server name, login credentials on my machine.
Your local machine can be specified as (local) or localhost or even just . (a period) as the SQL Server (machine) name.
If you can connect to SQL Server using Windows auth - that's probably the easiest way to go. So just try if that works, and if it does - perfect!
Otherwise, you need to find out what your sa (system administrator) account on your local server uses as a password - that's your key to everything, basically. If you don't know that password anymore.... you might need to reinstall SQL Server to get that password back.

Resources