I am trying to set up a legacy site written in ASP Classic on my local machine. I am using SQL Server 2008 and IIS ver 7.5.
I am running into an error when I try to open a connection to the database.
I used the advice in this post
to use a .udl file to create and test my connection string so I know the connection string works. I am using Windows Authentication and I am certain the app pool that is running this site has access to the database as I use the same pool for multiple sites and they can all connect fine.
When opening the connection I am trying to run a stored procedure, if I just write out the stored proc string and run it directly in my database it works as expected.
Here is the code:
Const adUseClient = 3
Const adCmdStoredProc = 4
Const adOpenStatic = 3
Const adLockBatchOptimistic = 4
dim connectstring,sql
connectstring = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=my-database;Data Source=(local)\SQLEXPRESS"
sql = "MyProc '" & param1 & "','" & param2 & "'"
set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockBatchOptimistic
' this is where it is failing
rs.Open sql, connectstring, 3
One of the problems is the error I get seems to be generated by IIS, it simply says:
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.
When I click on the "click here" link it takes me to a general page about running ASP Classic sites on IIS 7, I couldn't find anything that seemed relevant to my error though. I can't seem to find where to get information about the error. As a last resort I checked in Event Viewer->Windows applications logs but there was no entry for my errors.
I've Googled and tried multiple permutations on the connection string but to no avail. If anyone had any advice on how to solve this problem, or even an idea of where to look for a solution I would be grateful. Thanks much!
**EDIT: **
Ok I changed IIS settings to show errors in the browser and now I am getting an error message that is a bit more useful, here it is:
Microsoft OLE DB Provider for SQL Server error '80004005'
Cannot open database "rw-gp" requested by the login. The login failed.
Now when I Googled this I found that this can often be a permissions issue. As you can see I am using Windows authentication and I am running the site under an app pool that has permission to connect to the database. I have multiple ASP.NET sites set up locally that run in this app pool and they can connect using integrated security. I'm not sure what is going wrong, does anyone have any suggestions?
An ASP Classic script always runs using impersonation (this is different from ASP.NET where impersonation is off by default).
Hence the user that needs access to the DB by virtue of your use of SSPI needs to be the user being impersonated.
The impersonated user is by default the the IUSR account specified as the anonymous user however if you have turned on windows integrated security then user may well by the user account the the client browser is running under. In either case you need to make sure that the user being impersonated has access to the DB or stop using SSPI.
If you are only using anonymous access you can specify via IIS manager that the account to use for anonymous access is the app pools identity.
Related
Sorry for possible dublicate.
I am trying to connect to my MySQL database from my LotusScript code (in some of my legacy projects):
Option Public
Option Declare
UseLSX "*LSXODBC"
Sub Initialize
Dim mysqlConnection As New ODBCConnection
Dim sqlQuery As New ODBCQuery
Dim result As New ODBCResultSet
Call mysqlConnection.ConnectTo("url","root","111111")
If Not mysqlConnection.IsConnected Then
MessageBox "No connection. Try again later."
Exit Sub
Else
MessageBox "Connection success."
End If
End Sub
I can't figure out what is the correct way to set the url of my database in LotusScript. I have already tried many variants of possible solutions, but nothing worked, also found many different urls, but also not helped.
Situation:
For example, I am trying to connect to my localhost MySQL base in port 3306 with name "test_db".
Question:
How must the url looks like for this?
p.s. also, if you have more possible ways to connect to MySQL DB from LotusScript - I will be very glad to see them.
Thanks.
As per the documentation for the ConnectTo method of ODBCConnetion class, you don't specify a URL. You specify a Data Source Name, otherwise known as a DSN. This is a name that you assign when you configure a connection in the 'Data Sources (ODBC)' tool on the Windows machine where the code will be executing.
On Windows 10, the 'Data Sources (ODBC)' tool is found in the Control Panel listed under Administrative Tools. On a Windows 2008 server that I happen to have handy, Administrative Tools is directly on the Start Menu. I'm sure they've hidden it in other places on other Windows versions. (I have a dim memory of it being under 'Accessories' on some versions.)
Note that on 64 bit versions of Windows, you need to be cognizant of whether your code is running in a 32 bit environment - as it is if it runs in the Notes client, or in a 64 bit environment, which it might be if it is running in background on a Domino server. There are separate 32 and 64 bit versions of the 'Data Sources (ODBC)' tool, and it does matter which one you use. If you're at all unsure, run them both and configure the same DSN name in each of them,
I am developing an ASP classic website that connects to a MS Access database and display data at real time (I know MS Access is not the best option for this purpose, but my company uses it for everything, so I just decide to use it for now). When the MS database is on my hard disk drive (C:), it works fine. But when I move the database to one of the network locations, such as U:\tracking, it gives me this error:
Microsoft JET Database Engine error '80004005'
The Microsoft Jet database engine cannot open the file 'U:\tracking\database.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
I know it is probably due to the security permission (read and write) about creating temporary files (.ldb) for MS Access database. I reset the security permission on the U:\tracking folder, which contains the database, but it did not work. I even gave full control to every account listed in the "Group and user names" session, but the error was still there.
I also checked my Authentication setting in my IIS manager. The only enabled setting is Anonymous Authentication, and I use Application pool identity at this point. If I use specific user, I may add it to the above permission list and give it the appropriate permission, but I cannot guarantee it is appropriate. Any ideas about what I should do to connect to the database on the network location? Any help would be appreciated!
Following is the simple code I use to connect to the database:
Dim dbCon
Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Provider = "Microsoft.Jet.OLEDB.4.0"
dbCon.Open = "U:\tracking\database.mdb"
Consider using the ASO connection string parameter as this W3Schools page indicates.
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0"
conn.open server.mappath("database.mdb")
conn.close
%>
Also, path names do not need to be explicitly defined if server map targets the root directory. This is especially true since backslashes prove problematic for web URLs that use forward slashes.
I am calling this rs.exe script to run and export the report:
rs -i RunReport.rss -s http://localhost/reportserver -u myUsername -p myPassword -e Exec2005
The error I get is:
Could not connect to server: http://localhost/reportserver/ReportService2005.asmx
Currently all of our reports are set up to use 'Credentials supplied by the user'. If I go to the report and input the username and password, it runs just fine. It just doesn't work running the script.
When I change the report's datasource to use Windows Integrated Security, the script works.
Any ideas on how what I'm doing wrong? Or alternatively, is there a way to change the report's permissions to Windows Auth and then change it back?
SSRS 2012
My rss script is
Public Sub Main()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim format as string = "EXCEL"
Dim fileName as String = "C:\test.xls"
Dim reportPath as String = "/MyDirectory/Report1"
' Prepare Render arguments
Dim historyID as string = Nothing
Dim deviceInfo as string = Nothing
Dim extension as string = Nothing
Dim encoding as string
Dim mimeType as string
Dim warnings() AS Warning = Nothing
Dim streamIDs() as string = Nothing
Dim results() as Byte
rs.LoadReport(reportPath, historyID)
results = rs.Render(format, deviceInfo, extension, _
mimeType, encoding, warnings, streamIDs)
' Open a file stream and write out the report
Dim stream As FileStream = File.OpenWrite(fileName)
stream.Write(results, 0, results.Length)
stream.Close()
End Sub
I had the same error, it was due to a mistake in the configuration: the script was set to run against the Report Manager URL and not the Web Service URL (both can be found in the Reporting Services Configuration Manager). Switching to the Web Service URL solved it for me.
(I reckon you've found a workaround in the last 3 years, but I'll put this here if someone else is struggling with the same problem)
Came across the same issue. Addressed it by changing the Reporting Service Configuration Manager database credentials from Integrated Security to SQL server admin account.
I had a very similar problem. For me, getting rid of the default credentials fixed it. I asked our network guy to make a set of generic credentials (with a static password) and used that instead.
rs.Credentials = new System.Net.NetworkCredential("ACCOUNTNAME", "PASSWORD", "DOMAIN");
Let me know if you still have trouble with this. I spent a lot of time on errors related to this. You also might be able to check your SSRS log files for more information.
I had the same error message (Could not connect to server: http://localhost/reportserver/ReportService2010.asmx).
I was able to solve the issue by re-creating the report server database using Reporting Services Configuration Manager.
Connect to SQL Server using SQL Server Management Studio
Delete the report server database (called ReportServer or ReportServerSQLExpress)
Start Reporting Services Configuration Manager (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft SQL Server 2012\Configuration Tools\Reporting Services Configuration Manager )
Choose Database
Click Change Database and following the Wizard to create a new report server database
I had the exact same problem as you. For me it was caused by a Windows Credentials was somehow created for that URL. I've seen this happen to users also, but at the time I did not know how to resolve the message. They just signed in and kept moving. For me, the issue I was having was not isolated to chrome. I could also not use the command line to execute a tool (RS.exe), the command line said 'Could not connect to the server'.
The gcod049/reports URL issue was resolved after I deleted the saved credentials in Windows Credentials Manager.
Fig1: Sign in issue
Fig2: RS.exe issue
Fig3: Credentials Mgr
-- Control Panel\All Control Panel Items\Credential Manager
-- remove from vault: "gcod049"
Fig4: RESOLVED
-- browser sign in prompt gone
-- RS.exe connects to the server
I am new to classic ASP. I would rather ask question than do hour of research to solve my problem.
I am accessing access database and getting the following error.
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/default1.asp, line 30
The culprit line is this
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("c:\database\MyDatabase.mdb")
Well, I do not have Access installed but I copied the .mdb file to the specified folder, will it work that way? I am familiar with SQL Server, and that has to run in order to retrieve data from it.
It uses ADODB but I can't file the DLL. Can someone specify the DLL for me. What I have to do to get it working. Just registering it will work using regsvr32 my.dll?
I could not find a connection string (I usually use a connection string to connect to my SQL Server). Do I need one for Access database in this case?
Please help
It's been a few years for me, so this answer might be a little out of date. Also, since the Access db ends in .mdb, I'm assuming that it's a pre-2007 database.
Yes, just the file should work. Access does not need to run, it just needs to read the file. However, you may need certain components installed to talk to the Access database (used to be MDAC
- http://www.microsoft.com/download/en/details.aspx?id=1953, not 100% certain if it still is). MDAC contains the JET engine, which classic ASP uses to talk to Access files.
As for the connection string, this web site that provides some examples of access connection strings: http://connectionstrings.com/access
edit - adding more info
Just in case I'm not following the comments correctly, here's an example of how to connect to the Access database through Classic ASP:
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = "c:\database\MyDatabase.mdb" ''# Server.MapPath is not needed, since we are providing the whole path already
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & MdbFilePath
When running the code above, do you receive the error still? Also, what's the set up you're running (IIS7, IIS6, 32bit, 64bit)?
I have an access 2000 application to manage. The DSN is pointing to the production Postgresql database and I'd like to point it to the one running on my machine for testing.
The problem is, I can't figure out how to change it. I tried running odbcad32.exe, and I did see the DSN and was able to change it to what I wanted (and it did pass the "test connection" test), but it still seems to be connecting to the old production dsn. I confirmed this by checking the connection logs that get dumped to C:\. I searched the registry for the production server's name; I could not find it (and I verified that my changes were getting posted to the registry. I searched the entire project's forms' sources for the server name, I could not find it there either.
Where else could Access be getting the dsn from?
Don't use DSNs. I much prefer DSN-Less connections as it is one less thing for someone to have to configure on each PC and one less thing for the users to screw up.
Using DSN-Less Connections
ODBC DSN-Less Connection Tutorial Part I
HOWTO: Use "DSN-Less" ODBC Connections with RDO and DAO
Carl Prothman's Connection String Home Page
Relink ODBC tables from code
Also it's easier to have a setup that uses a development connection string for you and a production connection string for everyone else. For example, assuming your users only get MDEs/ACCDEs, you could use the following function to determine which connection string to use
Public Function tt_IsThisAnMDE()
On Error GoTo tagError
Dim dbs As Database
Set dbs = CurrentDb
Dim strMDE As String
On Error Resume Next
strMDE = dbs.Properties("MDE")
If Err = 0 And strMDE = "T" Then
tt_IsThisAnMDE = True
Else
tt_IsThisAnMDE = False
End If
Exit Function
tagError:
Call LogError(Application.CurrentObjectName, "")
Exit Function
End Function
Apparently MS Access stores the whole connection string, not just DSN name. Here is what I see opening .mdb file in Notepad:
DSN=SQL-Northwind;APP=Microsoft Office 2003;WSID=DELLNOTEBOOK;DATABASE=Northwind;Network=DBMSSOCN;Address=LOCALHOST;Trusted_Connection=Yes
MS Access comes with Linked Table Manager however it won't update DSN once it's changed (at least not for me).
I guess your only choice is to delete a link and create a new one.