0

I'm running Windows 10 Home (version 1709), using SQL Server 2014 on my local machine, and IIS (version 10.0.16299.15). Browser is Chrome.

I have set up an ODBC connection successfully (see code comments), and am calling it by name. I am not supplying username/password, since I am using Windows authentication. IIS for the Web site is set up as "Application user (pass-through authentication)"

As you can see my my commented-out lines, I've tried 3 different approaches: (1) creating cn.ConnectionString and using cn.Open; (2) prefixing the DSN with "DSN="; and (3) just using the DSN. But they all give the same output (see below).

My code in the Web page is:

<%
response.write("Start<br>")
set cn = Server.CreateObject("ADODB.Connection")
Set cmd = Server.CreateObject("ADODB.Command")
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_test"

' This is an ODBC connection DSN, Windows authentication
' Platform: 32/64 bit; Driver: SQL Server Native Client 10.0

' 1st solution
'cn.ConnectionString = "Provider=SQLOLEDB; Server=(local); Database=sample"
response.write("Ready to open connection<br>")
'cn.Open

' 2nd solution
'cn.Open "DSN=SSNC10UserEnvy360"

' 3rd solution
cn.Open "SSNC10UserEnvy360"
response.write("Connection Object Opened<br>")
cmd.ActiveConnection = cn
cn.close
response.write("Connection is closed<br>")
%>

Output in browser is the following generic message (even though I've set IIS to "detailed"** for this Web site):

Start
Ready to open connection
An error occurred on the server when processing the URL. Please contact the system administrator.
If you are the system administrator please click here to find out more about this error.

What am I doing wrong that I can't connect??

JohnC48
  • 21
  • 5
  • You first need to enable sending errors to the browser in the IIS ASP section of your web application. See https://stackoverflow.com/a/29962918/692942 – user692942 Jan 05 '18 at 00:32
  • Thank you! In IIS Mgr, under Sites, I selected the site I'm using, double clicked on ASP, and set both "Enable parent paths" and "Send error msgs to browser" to True. But I'm still getting the generic msg, which happens to be the msg in "Script error message". FYI, I see in my application event viewer, every time I refresh the asp pg, there's an info msg for MSSQLSERVER for task category, "Logon". Am I actually successful in my Open call, but failing with another, hidden, error? – JohnC48 Jan 06 '18 at 19:20
  • 1
    Resolved. I realized that the information-level MSSQLSERVER "logon" messages in the event log were actually failure messages! I resolved both of them in the Management Studio: one by adding my logon (NT AUTHORITY\IUSR) to the security/logins list; and the other by adding permissions to the DB. – JohnC48 Jan 12 '18 at 01:47

1 Answers1

0
 <% Baglanti = "Driver={SQL Server};Server=127.0.0.1;Database=MYDB;uid=user;pwd=pass"
    Set bag = Server.CreateObject("ADODB.Connection")
    bag.ConnectionString= Baglanti
    bag.Open

    set deneme = server.createobject("adodb.recordset")
    SQL="Select * from MYDB.dbo.denemeler order by id desc"
    deneme.open SQL,Baglanti,1,3
    %>

My worked code up. SQL connection no problem