I am debugging some old ASP code and have stumbled upon the following error:
Server.CreateObject Failed
Here's the line of code where I got the error:
Set Session("SessionBoolian") = Server.CreateObject("DBUtils.SQLExpression")
Where is DBUtils.SQLExpression located? I can't seem to find a reference to it in the code. How is it set?
I do have a DBUtils.dll in my bin folder, is there a way to look inside a DLL to find out if there's a SQLEXpression method there?
DBUtils.SQLExpression is most probably an ActiveXDLL. Your best bet is to search for the DBUtils.dll or DBUtils.SQLExpression.dll file.
If it's available, you may need to register it to the COM server using regsvr32 i.e. type regsvr32 D:\MyPath\DBUtils.dll in the run dialog and press enter.
You may also want to do a bit of error handling before setting an ActiveXObject in the session and see exactly what is the error. Something like this:
Dim sqlExpression
sqlExpression = Nothing
On Error Resume Next
Set sqlExpression = Server.CreateObject("DBUtils.SQLExpression")
If Err.Number <> 0 then
Response.Write "#: " & Err.Number & ", Source: " & Err.Source & ", Description: " & Err.Description
Else
'Rest of your code
End If
It seem that is a third party active-x plugin. Your posted code snippet creates an instanz of that and saves into a seesion with attribute 'SessionBoolian'.
Related
I write the following piece of codes :
rst.Open(strSQL & Request.QueryString("C-PLACE")), conn, 0, 1
But got the following error. However, if the querystring is in English or just number, no error will pop out. Any guru can help please ?
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
/deliverable/GetMemberTest.asp, line 19
It's going to either be passing an encoding variable to the server, or in the case of your error, its saying "too few parameters". In this case, the parameter is "C-PLACE" and its suppose to be passed to your asp script from the previous page's link, something like:
/deliverable/GetMemberTest.asp?C-PLACE=THECPLACE
https://www.w3schools.com/asp/coll_querystring.asp
(citation about query strings)
or something like that .. obviously its not actually "THECPLACE", but just saying a QueryString("VARIABLENAME") looks to the URL of the previous page to pass the parameter to the script, so that error message should of done something to add a ? mark = C-PLACE= to something, and we aren't seeing that. So something on the previous page that was suppose to add this when they click a submit button didn't do it's job, or the script is just getting run on its own without the proper previous page's work being done to prepare it to execute properly on the following page.
It will also be of note that these types of things are easily hacked through sql script injection, so if you aren't validating your url first, someone could use some code to escape out of your sql and add their own code, such as one to drop your tables ..., so make sure you validate the variable FIRST instead of dumping it straight into your code. I can give some guidance into that later, but first lets figure out your problem.
(side note - can i request strSQL from you? Can you put this line in before that line:
<%
response.write("strSQL is " & StrSQL & "<BR>")
%>
All this code does is display what is stored in the StrSQL variable, see if we can figure out what is going on here. Also take note that your error message indicated that it expected 2 parameters, so we are missing 2 for this script to run properly.
EDIT - try this encoding:
<%
Response.CodePage=65001
Response.Charset="UTF-8"
Response.ContentType = "text/html"
%>
Try this strSQL, you didn't need the Response.Write and on C-PLACE you want to use '' instead of "" because the "" will exit you out of the SQL statement. Try this, and let me know how it works, but I still think we are going to need another parameter supplied to it, unless its getting one from the string and then it isn't actually counting the one supplied from the url perhaps.
<%
strSQL="SELECT * FROM DetailMemberInfo
WHERE C-PLACE=" & strSQL & Request.QueryString('C-PLACE'))"
%>
This is not the same as the other question because the advice in the other question fails to work for me. I'm specifically trying to determine what's different in my case that this doesn't work.
I'm working in Classic ASP. According to the docs I find online (here and elsewhere: https://www.w3schools.com/ASp/asp_ref_error.asp ), the ASP error object should have the following properties, among others:
Description: Returns a short description of the error
File: Returns the name of the ASP file that generated the error
Line: Returns the line number where the error was detected
Number: Returns the standard COM error code for the error
I have the following test code. Note error_log() is a custom function that writes text to a log file.
on error resume next
blah
if err.number > 0 then
error_log( err.number )
error_log( err.description )
error_log( err.file )
error_log( err.line )
end if
on error goto 0
The first two lines, number and description, are written as expected; but file and line are not. As best I can tell, the latter two properties are simply not available to my copy of ASP/VBScript. Why don't I have these properties?
I'm running what I believe is the latest (circa 2000) version of classic ASP VBScript. Straight from the horse's mouth: VBScript 5.8 build 16384
EDIT: attempts to run Server.GetLastError() fail. It appears I don't have that command for some reason. [CORRECTION: it runs but seems to have no data. See examples below]
New Minimal Example:
On Error Resume Next
blah 'This is our error. unrecognized variable'
Set error = Server.GetLastError()
response.write error.file
On Error Goto 0
response.end
This results in a blank screen. No error data is written.
Another test. Note "error" vs. auto-generated "err":
On Error Resume Next
blah 'This is our error. unrecognized variable'
Set error = Server.GetLastError()
response.write error.number
response.write " | "
response.write err.number
response.write "<br>" & vbCrLf
response.write error.description
response.write " | "
response.write err.description
response.write "<br>" & vbCrLf
response.write error.file
response.write " | "
response.write error.line
On Error Goto 0
response.end
Result:
0 | 500
| Variable is undefined
| 0
For starters, per user Lankymart, there is a difference between the automatic err object and the object returned by Server.GetLastError(). For this we need the latter of the two.
It seems that Classic ASP returns a slightly different error code: 500.100; so if you want to capture error data, you have to make an error page explicitly for that sub-code.
Info found here: https://stackoverflow.com/a/9407559/339440
Classic ASP has always returned a 500.100 status if there is a script
error[...].
If you want to catch Classic ASP script errors and be able to read the
Server.GetLastError() object in your custom error page (say for
logging) you need to provide a handler specifically for 500.100.
If you don't specify a custom 500.100 error then IIS will fall back to
your custom (or its own) 500 error page but Server.GetLastError()
won't provide any useful information about the error.
So error referencing "in place" doesn't work, and catching the standard 500 error doesn't work. You need to explicitly catch the 500.100 code. On a regular 500 error, Server.GetLastError() returns an object with no data in it -- which is exactly the problem I've been having.
So I made a copy of my site's 500 error page, and modified it to also write to my error log. Then in IIS I set that new file to be the error page for 500.100 errors. It appears to be working.
This doesn't entirely solve my problem, as I was trying to create a sort of try ... catch routine that could run inline. But it does give me the ability to simply log errors, which is very useful.
We're trying to read some log files for our application but FileExists is failing in every case. So I simplified the problem with this test code:
Dim filespec, msg
filespec = Chr(34) & "C:\Windows\explorer.exe" & Chr(34)
'filespec = "C:\Windows\explorer.exe"
'filespec = Chr(34) & "C:" & Chr(34)
'filespec = "C:"
'filespec = "default.asp"
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msg = filespec & " exists."
Else
msg = filespec & " doesn't exist."
End If
Response.Write(msg)
As you can see, we've tried testing with and without added Chr(32) (which is the double quote character). We're testing against the file C:\Windows\explorer.exe and the file C:\Windows\explorer.exe does exist on the computer hosting the asp files and the iis server. We even fail when simply checking to see if the C drive exist.
Additionally, it even fails if we try to see if the default.asp file exists and that file is in the same directory as our filetest.asp file.
Does anyone see why our FileExists is consistently failing? Thank you.
filespec = "C:\Windows\explorer.exe"
Without the additional quotes will work. To find a folder we need to use
fso.FolderExists
Instead of FileExists.
This still doesn't find the default.asp file in the same directory. But that problem is too far removed from our actual problem which is to look at log files on another drive. That problem is too far from this original question so I'll post that problem separately.
You may want to try to load the folder in to a folder object and loop through files in the folder object. Below is an example.
Set fso = CreateObject("Scripting.FileSystemObject")
FileToFind = "explorer.exe"
FolderToSearch = "C:\Windows\"
Set myFolder = fso.GetFolder(FolderToSearch)
For each myFile in myFolder.Files
If myFile.Name = FileToFind Then
Wscript.echo "Found " & myFolder.Path & "\" & myFile.Name
End If
Next
you do not need to insert additional quotes. removing your quotes will work just fine.
Dim filespec, msg
filespec = "C:\Windows\explorer.exe"
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msg = filespec & " exists."
Else
msg = filespec & " doesn't exist."
End If
Response.Write(msg)
In the past, I have only noticed that you need to insert additional quotes when using the wshshell.run since a space might be interpreted as additional arguments to the filename.
It appears that our problem is not in the VBScript at all. The app is running inside an ApplicationPool in iis. The Identity property of that Application Pool is the dynamically created applicationPoolIdentity user. This is a user with no permissions. So essentially, the application is running as a user which does not have access to any other drives. Therefore, it cannot find any file on any network drive. We will have to create an additional identity with the proper rights and set our applicationPool identity to use that custom account.
I found instructions on how to set this identity account here: http://technet.microsoft.com/en-us/library/cc771170%28v=ws.10%29.aspx
I'm working with a web application that performs some Excel automation (I know - not a preferred solution).
I am using Excel 2007 as my development platform but the target server uses Excel 2003. After experiencing a lot of headaches with the Excel 12 interop trying to be loaded on the target server even though I expressly selected Excel 11 during development, I have resorted to using late binding rather than early binding.
This has allowed me to get as far so as to instantiate Excel (and I can see the Excel process start in task manager on the target server).
However I am unable to invoke the Open method of the late-bound Workbooks object. It throws this error at me:
"Unable to get the Open property of the Workbooks class"
I have been experimenting with a few different things and have tried the following:
Try the same Workbooks.Open call using late-binding VBScript (e.g. a vbs file).
Try the same Workbooks.Open call using late-binding VBA code (e.g. in Excel).
Try the same Workbooks.Open call using late-binding .NET code in a Windows Forms application.
In all three cases, the Excel automation succeeds. It's only when I deploy the ASP.NET application that this error crops up. In a very simplified form, the code resembles:
Dim xlApp As Object 'Excel.Application
Dim xlBook As Object ' Excel.Workbook
xlApp = CreateObject("Excel.Application") 'New Excel.Application
xlBook = xlApp.Workbooks.Open("somefile.xls", , True, , , , , , , , , , , , False)
Does anyone have any ideas as to what might be happening? I checked the user that the Excel process starts as, and it is the same user that I successfully ran the Windows Forms .NET application as successfully. I had already opened Excel as this user to clear all the initial setup stuff.
I'm getting this same problem and I found some sites saying the following: Try going to file - options - add-ins - select diabled add-ins in the manage dropdown - click go - and enable anything in there.
It didn't work for me but it might for you.
Better a late answer then never...
When developing a VBscript make sure you handle the error that prevent closing your Excel Book correctly.
I got the same error as you, but I found out that when a error occurs within my logic, the interpreter doesn't close the Excel Book making it unavailable to further process.
Dim XLWkbk 'Excel workbook
Set xlApp = CreateObject("excel.application")
On Error Resume Next
Set XLWkbk = xlApp.Workbooks.Open("somefile.xlsm")
If Err.Number <> 0 Then ' Catch your error
WScript.Echo "Error while opening: " & Err.Number & " " & Err.Description
XLWkbk.Close False ' Close your workbook.
xlApp.Quit ' Quit the excel program.
WScript.Quit
Err.Clear
End If
WScript.Echo "Opened"
Be sure to handle the error with all function that operates on a file (SaveAs, Close, etc...)
Omitting the last argument fixed it for me.
xlBook = xlApp.Workbooks.Open("somefile.xls", , True, , , , , , , , , , , , )
I have moved an sql database from one server to a new one (detached/attached)
Now i experience some strange behavior as it does not work but NO error is displayed.
This is the code
<%
const database_dsn="PROVIDER=SQLNCLI10; SERVER=FR-2626\SQLLOP;DATABASE=Lop;Uid=admin-sql;Pwd=xxxx;"
response.write "Step 0//"
set conn=server.CreateObject("ADODB.Connection")
set RS=server.CreateObject("ADODB.Recordset")
conn.Open database_dsn
response.write "Step 1//"
req = "Select count(*) From tblArticleList"
response.write "Step 2//"
set RS = conn.Execute(req)
response.write "Step 3//"
%>
The program stops at Step 2; then nothing, no error is displayed...
I just don t know what to do..How can i get some error?
Thanks
Jonathan
Oh i partially found the answer for the error display.
In the Debug pane of the IIS directory configuration, Enable ASP debugging should NOT be checked...althought i thougth it should...
have you got your browser set to "show friendly http errors" this in conjuction with what you have already identified is the common causes I've had for not seeing an error message.
Shahkaplesh is also right that you can use Server.GetLastError() to get the last error that occurred but you shouldn't need to do this in this example.
When executing a query you don't use the "Set" command. I don't know why its not showing you anything, but your code should look more like this:
<%
const database_dsn="PROVIDER=SQLNCLI10; SERVER=FR-2626\SQLLOP;DATABASE=Lop;Uid=admin-sql;Pwd=xxxx;"
response.write("Step 0//")
set conn=server.CreateObject("ADODB.Connection")
set RS=server.CreateObject("ADODB.Recordset")
conn.Open database_dsn
response.write("Step 1//")
req = "Select count(*) From tblArticleList"
response.write("Step 2//")
RS = conn.Execute(req)
response.write("Step 3//")
%>
Yes, the parentheses on the "Response.Write" are optional. But I'm OCD like that and it makes troubleshooting a little easier.
You need to place error checking code to find out what the actual error might be.
I would suggest that you change you code like so:
<%
const database_dsn="PROVIDER=SQLNCLI10; SERVER=FR-2626\SQLLOP;DATABASE=Lop;Uid=admin- sql;Pwd=xxxx;"
'Its very important to add this line!!! '
On Error Resume Next
'Its very important to add this line!!! '
response.write "Step 0//"
set conn=server.CreateObject("ADODB.Connection")
set RS=server.CreateObject("ADODB.Recordset")
conn.Open database_dsn
if err.number<>0 then
response.write err.description
end if
response.write "Step 1//"
req = "Select count(*) From tblArticleList"
response.write "Step 2//"
set RS = conn.Execute(req)
if err.number<>0 then
response.write err.description
end if
response.write "Step 3//"
%>
And not to kick a dead horse but I'm doing something similar against an Oracle database and I've had two phantom problems I have yet to identify root cause but here's two things that made them go away.
1. Name all columns in a Query and Alias any that are calculated (sum, count, avg, etc.) So your query would become
req = "Select count(*) NumRows From tblArticleList"
2. Wrapping my query string in a call to cstr caused the result.EOF flag to be populated correctly rather than be returned with an empty or null value causing a simple DO WHILE NOT result.EOF Some Action LOOP to create an infinite loop until the web request timed out. So e.g.
response.write "Step 2//"
set RS = conn.Execute(cstr(req))
Nothing major just a couple tips if you get stuck and can't find out why. Follow the debugging advice above though, that's good info.
I think Server has a GetLastError method, which you can check to find out what error occurred while running any statement.
e.g. On error resume next
.... statement that could cause an error....
errorObject = Server.GetLastError()
For ASPError object, refer http://www.w3schools.com/asp/asp_ref_error.asp
Actually don't mean to be disagreeable, but yes you do need a Set there, as you are setting an object type and presumably wanting to use the return value at some point (if this wasn't just a test script which it looks like to me).
Also btw parentheses are not really correct there in Response.Write() as it does not return a value. They only happen to work on single parameter subs because you can put parentheses anywhere you like around expressions.
eg:
a = (b)
Response.Write ((("test"))&(1))