ASP can't connect to SQL Server database - sql-server-2008

I'm trying to get a classic ASP application to connect to a local SQL Server 2008 database. The app and database were built by someone else. I'm just trying to get them installed and running on my machine (Windows 7).
I'm getting the following error when when the ASP app tries to connect to the database:
Could not connect to database:
Error Number: -2147467259
Error Message: [ConnectionOpen (Connect()).] does not exist or access denied.
I don't see any messages in the Windows Event Viewer. I'm looking at: Event Viewer->Windows Logs->Application.
It's a fresh database install using a simple restore. The SQL Server install uses the default instance. SQL Server and Windows authentication are both allowed. I left the existing connection string (in the ASP code) in tact and just tried adding that to my SQL Server installation. Here's the connection string:
strConn = "PROVIDER=SQLOLEDB;SERVER=localhost;UID=TheUser;PWD=ThePassword;DATABASE=TheDatabase;"
To add that user to SQL Server, I went to Security/Logins in SSMS and added the user and the password. I selected the database in question as the Default database. I thought that might do the trick, but it didn't. Then, I went into TheDatabase, then went into Security there. I added a new user there, referencing the new user I had already added in server Security. Under Owned Schemas, I clicked db_owner and under Role Members I checked db_accessadmin and db_owner. None of this gave the ASP application access to the database. The sid values match in sys.database_principals and sys.server_principals for the login in question. I am able to login to SSMS using this login.
The app needs to execute selects against the database like this:
oConn.Execute('select * from someTable')
I'm not a DBA and am sort of grasping at straws here. How do I get this thing connected?
Thanks,
Jay

It occurred to me that SQL Server or the website in IIS might be running as users with the wrong permissions. Based on what I read, it's okay for SQL Server to be running as Local System, so I left that alone.
In IIS, my website was using "Application user (pass-through authentication)". This is set in the Basic Settings->Connect As ("Edit Site" dialog box). When I clicked "Test Settings...", next to Authorization it said "Cannot verify access to path (c:\mywebsitepath)." I increased access permissions on that directory, but that didn't help. In the "Connect As" dialog box, I then changed "Path credentials" to use "Specific user" instead of "Application user (pass-through authentication)". I set it to use the user that I log in to my machine as. After that, when I click the "Test Settings..." button, next to "Authorization" it says "Path is accessible (c:\mywebsitepath)." After that, the ASP website is able to connect to SQL Server just fine.
Since the connection string was using a specific SQL Server username and password, I'm not exactly sure why this fixed the problem, but it seems to have.

Related

Unable to Connect to MySQL local server 3306 in Power BI

I was about to start a Project using MySQL and Power BI for creating a dashboard but I faced a severe challenge. When I was going to connect MySQL database in Power BI, I faced an error like:
Microsoft SQL: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An established connection was aborted by the software in your host machine.)"
I am not able to find any solution for this over the internet.
Ok, so I had the exact same error and I got that resolved. So you'll need to ensure that the MySQL connector net is installed. And I made the mistake of importing the JAR file instead.
DO NOT DO THAT. Download and Install the msi package (If you're using windows) from this link. Connector Net Download Link.
Once that's installed.
Close Power BI if it's opened. (Basically restart Power BI).
Start the SQL Server. I'm using XAMPP.
Check this screenshot of the XAMPP Window with the MySQL server started.
Open Power BI and click on "Get Data" option. That will open up a pop up window asking you to choose all the different data sources.
Now comes the 2nd important point. Ensure you select "MySQL Database". Check this image for the MySQL Data source.
Click on "connect", and in the server field type in the IP address and the port number. and also specify the database name. Check this image for the input fields.
Click "ok" and if all goes well, you should see all the tables under the database in the "Navigator" window. I have selected 2 tables called "city" and "sdetails" under the database "school".
And from here, you can choose to "Load" or "Transform Data" and get on with visualizing it.
Note :
1. If power BI throws up an error window asking for credentials choose "Database Credentials". By default "Windows Credentials" would be selected.
2. Here, provide the username and password for your SQL Connection. The same credentials which you would use in your code based connections.
3. For XAMPP the default username would be "root" and the password would be an empty field.
4. Save the database credentials and try connecting to the database again and it should work.

Cannot connect to local sql server sqlexpress instance via java nor other tools

I installed SQL Server 2008 Express on Win 7 64. I can connect to it via SQL Server Management Studio using Windows Auth, but not SQl Server Auth. Following the directions in http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/, I feel I have properly configured for remote connections & sql server auth. Yet, when I try to login, I get an error stating that the login failed. Googling hasn't seemed to help for the answers do not make sense, do not seem to apply. One of these was a suggestion to change the dynamic port to blank, hard code the port. Since this tool is by default not installed in such fashion, I have a hard time believing this is the actual problem. Not one post I found explained why that should be changed.
The exact message is:
Cannot connect to bvl-wd-bturner\SQLEXPRess
Additional information:
Login failed for user 'DTN\bill.turner'. (Microsoft SQL Server, Error 18456)
I attempted to login with the following credentials:
Server type: Database Engine
Server name: bvl-wd-bturner\SQLEXPRESS
Authentication: SQL Server Authentication
Login: DTN\bill.turner
Password:
For what its worth, logging on using Windows auth, I look at the connection properties. The User Name complies with the login above. The Server Name is the same (in fact copy/pasted to be sure for both).
=== UPDATE ===
Windows Firewall is off.
I tried also, even with my reservations, to hardcode the port number, removing the "0" on all dynamic ports and setting the port to 1433. No luck. :-(
=== UPDATE 2 ===
I realized I needed to create a SQL Server account and have done so. I can now log in via SSMS with the following credentials. However, I seem to be unable to login through DbVisualizer or a test java file with the follow:
Driver is net.sourceforge.jtds.jdbc.Driver
Connection url is jdbc:jtds:sqlserver://bvl-wd-bturner:1433/host
The credentials I now use successfully in SSMS are:
Server type: Database Engine
Server name: bvl-wd-bturner\SQLEXPRESS
Authentication: SQL Server Authentication
Login: local
Password:
At this point I have to believe it is something obvious I am missing, but have yet to find it.
The login: DTN\bill.turner looks like a Windows login, not a SQL server login which has no domain component. Is DTN your domain name? If so, providing this with the SQL login will probably confuse the client into trying windows authentication, which will then fail if the login doesn't exist.
What is the name of the SQL server login that you have created (within the SQL management studio)? It shouldn't have a domain\username format, it should just be a username on its own. You also need to make sure that you select SQL authentication when connecting.
Try adding your current logged in account (Windows) to the Local Administrators group on your computer.
The link posted at the beginning,
http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/
Plus this article on setting the default log on database:
http://blog.sqlauthority.com/2008/11/04/sql-server-fix-error-4064-cannot-open-user-default-database-login-failed-login-failed-for-user/
Solved this problem for me. Hopefully it will help others who wind up here.

Cannot to connect to SQL server 2008?

I have been trying all kinds of tricks - from enabling TCP/IP, adding exception to firewalls to poking bill gates vodoo doll. But nothing seems to work for me. Is it really that difficult to connect to sql server 2008 via management studio ? Maybe, robbing a bank would be easier.
While i figure out which bank to rob, can you help me to fix the problem ?
When I try to login to sql server 2008, this is the error i get-
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)
The links i tried so far -
blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/
and some more random links on the net.
When you installed SQLServer, there are several options that may affect the way SQLServer runs and how you have to connect to it. The link you included in your question that points to the sqlauthority blog has an additional thread posted by Vince. Be sure to follow those instructions so that SQLServer will be set to listen on port 1433 and not a dynamic port.
Also, when you log-in, if it tells you that the login fails (e.g., for xxx\yyy), then you probably missed the option in the install to add the current user as an authorized users. In that case, you will have to log in through SSMS using SQL Server Authentication, and provide sa as the username and the password that you set during the install.
After you log in, you can add your Windows user account to the list of authorized users by expanding the root Security folder in the SSMS object explorer, right-click Logins and select New Login. From there you can search for your user account and add a Windows authentication user. That will make it possible for you to log in using Windows Authentication so you won't have to type your password every time you launch SSMS.

SQL mangement user error

When i am creating users in SQL management studio i create them under the server name and then i create them under the database but when i try to log on using the user name and password i cant. getting erro saying
> TITLE: Connect to Server
Cannot connect to LAPTOP-RED\SQLEXPRESS.
ADDITIONAL INFORMATION:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=233&LinkId=20476
BUTTONS:
OK
And the suggested solution from the help link is:
User Action
Use the SQL Server Surface Area Configuration tool to allow SQL Server
to accept remote connections. For more information about the SQL
Server Surface Area Configuration Tool, see Surface Area Configuration
for Services and Connections.
Which is what you have to do. By default the SQL Express Server isn't configured to allow remote connections.
hi I faced same issue in MicroSoft sql server 2008.
this error occurs while user limit exceeded, as you have set max connection to 1 and if someone is already logged in (or using any webpage which access your server) then it will not allow anyone to access directly or indirectly. to solve this issue simply follow following steps:
stop all web services.
open services.msc using RUN and ****restart sql server** and do not start any service which uses your sql server, so that you will be able to log in using sql server management studio.
now open sql server management studio and click on New Query button.
It will ask for user name and password use your login name and password.
run these scripts one by one sp_configure 'user connections', 0
go
6.reconfigure with override
after this restart your sql server it will show a confirmation message click on OK.
Bingo
It works. please don't forgot to vote ;-)

How to make SQL Server find a login matching the name provided?

I have just restored a database backup to my local SQL Server express instance.
In management studio under the server instance node I went to: Security -> Logins -> New login...
Then I filled in a login name, password and chose SQL Server authentication. And at the bottom I selected the newly restored database to be the Default database.
At the User Mapping 'tab' at the left, I mapped the user to the newly restored database and gave it "db_owner" role.
When I try to login the following error is given in the log:
Login failed for user 'username'. Reason: Could not find a login matching the name provided. [CLIENT: ]
How can I make SQL Server find the login matching the name I provided?
Other info:
Named pipes are enabled
TCP/IP is enabled
Remote connections are allowed
Please make sure you have selected "SQL Server Authentication" mode for user you created from
Server > Security > Logins option.
Another possibility, is that you created the SQL Server login using Management Studio, and the option requiring the user to change the password on first login was checked. If you didn't immediately login with Management Studio, and change the password, then the attempt to login from the other machine is not able to pop up a dialog box to change the password and so it fails.
try it by removing user and create again.
This is old but for some one who encounters error for ASP.Net Core 2.2 using EF core and VS Code, I got error
Error Number:18456,State:1,Class:14
Login failed for user 'sa:password=MyPassword'.
I looked logs from SSMS and found error as
Login failed for user 'sa:password=MyPassowrd'. Reason: Could not find a login matching the name provided. [CLIENT: MyIp]
After searching here and there i found that I have to add Persist Security Info=False in connection string, so my connection string became like
"Default":"Persist Security Info=False;User ID=sa;Password=MyPassword;Initial Catalog=MyDb;Server=MyServerIp"
I found this format from Microsoft Docs. After that it worked fine.
persist security info=false is default. I didnot found any reason why my connection string without it was not working. From here