I installed SQL Server 2017 Express on Windows 10. I couldn't get it to connect using adodb. I am able to connect to it from SQL Server Management Studio, I can query the tables, etc, it works fine, but not from asp.
This is from my asp classic code:
connectionString="Provider=SQLNCLI11;Server=LENOVO\SQLEXPRESS;Database=mydb;Trusted_Connection=yes;"
set cn=server.createobject("adodb.connection")
cn.open (connectionString)
I can't figure out what would be the reason. It connects when I use 'master' instead of 'mydb'. I created a new database with some new tables.
It may not be related, but I don't have a password for windows, this is my personal computer so I didn't want to have login credentials. I'm not sure if that could be the reason. I didn't try creating a user, but if that's what is the issue here I will create one.
It worked, I went into the Security\Logins -> BUILTIN\Users -> Properties -> User Mapping -> checked 'mydb' -> checked db_accessadmin and db_owner. Tried my asp code again, it worked.
Related
I have a local SQL Server 2017 Express database which I can connect to from a C# console app with the connection string
SERVER=(LocalDB)\MSSQLLocalDB;DATABASE=brain;uid=brain;pwd=xxxxxx
It works fine from the .NET app.
However I wanted to quickly knock up an ASP classic page so I could see some of the data from a browser and it doesn't work using that connection string.
I tried changing the server to what
SELECT ##SERVERNAME
returned which was HP\LOCALDB#0B1B079F
However that didn't work either.
I looked at some other answers which were to add a pass in the firewall and I did that even though the SQL Server and app/web page are on the same machine, my laptop. However that did nothing either.
I am just wondering why the C# App works but the ASP page doesn't. The rest of the ASP executes just not the connection to the DB.
The ASP code is just
Set objCon = CreateObject("ADODB.Connection")
objCon.open "PROVIDER=SQLOLEDB;SERVER=(LocalDB)\MSSQLLocalDB;DATABASE=brain;uid=brain;pwd=xxxxxx;"
objCon.CommandTimeout = 0
Set objRS = objCon.Execute(strSQL)
It fails on the objCon.open line.
Just not sure why a command prompt running a console app (for the moment until its made into an APP), works but IIS ASP Classic using the same connection string doesn't.
We can take advantage of the SQL Server Object Explorer in VS to obtain the connection string. It should be in line with the norms. After we added the SQL Server by using Add Server wizard, we can check the connect string property of the SQL Server.
Under this circumstance, the ADO.Net library and Entity Framework can connect to the SQL Server properly on my side.
Feel free to let me know if the problem persists.
I am trying to connect to a database created in the SQL Server 2016 express edition, through Data Source Configuration Wizard in VS2017 Express edition, with SQL Server Authentication.
I created the user in SQL Server, and when I test the connection works perfectly, but vs displays the error. Also in Server properties, I set up SQL and Windows authentication.
I finally found a solution. I checked the checkbox remember password while creating connection string...and now can retrieve data for that user. In connection string is added persisted security=true. Still don't know why this need to be checked, because I follow example without persisted security, and there it worked, but on my PC didn't.
Trying to connect a classic asp page to sql server express 2014 using a dsn.
I've created a new database (in sql server management studio) called warehouse, with a table called users. I've added a new login called user1 with a password and mapped it to the warehouse database
I've created an ODBC System DSN on the same machine, using sql server native client 11 driver called SQLServer2 with integrated windows authentication, and a default database warehouse. Testing the connection at this point works fine!
On the ASP page I'm using:-
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "dsn=SQLServer2;uid=user1;pwd=xyz;"
Error:- Microsoft OLE DB Provider for ODBC Drivers error '80040e4d'
[Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot open
database "warehouse" requested by the login. The login failed.
I'm pretty sure that its a permissions issue and that the connection string is OK otherwise but after hours and hours of trying different strings, different users, I can't seem to get the damn thing to connect
If Anyone can throw any ideas my way I'd be very grateful. Thanks!
The way you are describing the problem the DSN uses integrated security so your credentials might be ignored and the database is called using the application pool identity.
If you have no specific reason why you need to use a DSN I would recommend using a connection string like the following:
objConn.Open "Provider=sqloledb;Server=yourdbserver;uid=user1;pwd=xyz;Database=warehouse"
A look into your SQL server log might give you a hint as to which user is actually failing to connect to your database.
I think you should have done something like this
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString "dsn=SQLServer2;uid=user1;pwd=xyz;"
objConn.open
I have a database set up that is to gather planned vacation time that I need to put on sharepoint asap. It's completely done, except for that the application login is failing for anyone that tries to use it that does not have their corprate login (windows authentication) listed in the security logins folder.
The connection string is fine, as it works properly on my computer and another programmer's computer, but not on my boss's computer. I can also login to sql server using the application login that is listed in the connection string.
I'm using SQL Server Managment Studio 2008, the server is 2005.
Edit#1: Further research led to finding this page: http://sql-articles.com/articles/troubleshooting/troubleshooting-login-failed-error-18456/
And my error is state 11. It's listing a windows authentication in the error log even though I specified otherwise.
Edit#2: My Connection String is this:
Driver={SQL Server};Server=ServerName\ThingIdontUnderstand;Database=ReportingDevDB;Trusted_Connection=FALSE;uid=Derp;pwd=qwerty;
Edit#3: Solved! See comments on this post for answers since I can't answer my own questions yet.
You check for the version when you connect to the instance through SSMS it will show it beside the server name under Object Explorer. Or just use the query SELECT ##VERSION
I would suggest simply creating a corporate windows group and adding those individuals to it, and then simply add this group as a login to your instance of SQL Server.
I am migrating a classic ASP web app to new servers. The database back end is migrating from SQL Server 2000 to SQL Server 2008, and the app is moving from Win2000 x86 to Win2003R2 x64. I am getting the above error on every single stored procedure call within the application.
I have verified:
Yes, the SQL user is set up, using correct username and password
Yes, the SQL user has execute permissions on the stored procedures in the database
Yes, I have updated the TypeLib references to the new UUID
Yes, I have logged into the database via SSMS with the SQL user id and it can see and execute the stored procedures just fine in SSMS, but not from the web app.
Yes, the SQL user has the database set as its default database.
The most frustrating thing is it works fine on the DEV server, but not on the production server. I have gone through every IIS setting 5 or 6 times and the web app is set up precisely the same in both environments. The only difference is the database server name in the connection string (DEV vs prod)
EDIT: I have also tried pointing the prod web box at the dev database server and get the same error so I'm fairly sure the issue isn't on the database side.
Are you sure that you are really connected to the instance and database you think you are (in the App)? It only takes the wrong DB in the connection string to override the default database for the user.
Can you execute some inline SQL on the connection like:
SELECT ##SERVERNAME AS SERVERNAME
,DB_NAME() AS [DB_NAME]
,CURRENT_USER AS [CURRENT_USER]
It might be the schema. Have you set the default schema of your user in the database you are using?