Reputation: 707
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.
Upvotes: 0
Views: 551
Reputation: 7532
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.
Upvotes: 1