The Microsoft Access database engine could not find the object test.13.csv - asp-classic

I am working classic ASP project. In this project there is option for users to upload CSV.
Now what is happening is, if I upload CSV file with more than one dot, for example test.13.csv then I get:
The Microsoft Access database engine could not find the object 'test.13.csv'. Make sure the object exists and that you spell its name and the path name correctly
But if I save the same file as test.csv, then it takes file properly.
So can anyone tell me how can I allow my code to accept more than one dot in csv file?
I am using following provider :
sFileDSN = "Provider=" & msdbProviderString() & ";Data Source=" & objFile.Folder & ";Extended Properties=""text;HDR=YES;IMEX=1;MaxScanRows=0;ImportMixedTypes=Text;"""

You can enclose your filename in single quotes like this:
sFileDSN = "Provider='" & msdbProviderString() & "';Data Source=" & objFile.Folder & ";Extended Properties=""text;HDR=YES;IMEX=1;MaxScanRows=0;ImportMixedTypes=Text;"""
Here is a reference, it doesn't specifically mention periods but does address other special characters:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms722656(v=vs.85).aspx

Related

Automatically save QuickTime Recording

I'm trying to automatically save a Quicktime recording to a directory with an specific file name including date and time.
To create the path, the I created a input dialog to create the folder and a subfolder with the date.
tell application "Finder"
activate
set DateStamp to short date string of (current date)
set patientname to text returned of (display dialog "patient name:" default answer "")
set folderpath to POSIX path of (choose folder with prompt "choose folder")
do shell script "/bin/mkdir -p " & quoted form of folderpath & "/" & quoted form of (patientname) & "/" & DateStamp
end tell
Then I open Quicktime and start the Recording. After stopping the recording, the new record should be saved under the specific name + date + time in the new created subfolder.
tell application "QuickTime Player"
activate
repeat
set tdoc to new movie recording -- document "Movie Recording"
say "Ready!"
delay 1
repeat while exists tdoc
delay 1
end repeat -- the recording is stopped
say "Stop!"
tell front document
set TimeStamp to time string of (current date)
set fileName to POSIX path of folderpath & "/" & patientname & "/" & DateStamp & "/" & patientname & "_" & DateStamp & "_" & TimeStamp & ".mov"
save it in POSIX file fileName
close
end tell
end repeat
end tell
After saving the new Record should close and a new recording window should appear.
However, there is always an error saying, I have no writing permission to save the file.
screenshot
What do I have to change? i have no idea.
Although I have to say that I am very new to apple script. thanks in advance!
PS: I'm Using QuickTime Player Version 10.5 (1148.4.1)
and MacOS Ventura 13.0.1

Ajax toolkit issue with file name (illegal character in file name)

here is some strange issue, windows systems are not allowed to include pipe (|) sign in the file name while mac os allowed that. now when I upload the file from the mac system with the pipe sign in the file name it is throwing me errors like illegal characters in the file name(Illegal characters in path.)
so it looks like the issue is when we upload files in the windows system it is not allowing the pipe sign. so resolve that I have tried to change the file name before upload and for that i have tried OnClientUploadStarted function but it never its the function.
<aspa:AjaxFileUpload ID="AFUMedia" CssClass="AjaxFileUpload" runat="server" AllowedFileTypes="mpeg,x-zip-compressed,mp3,zip" MaximumNumberOfFiles="10" OnUploadComplete="AFUMedia_UploadComplete" OnClientUploadComplete="uploadComplete" OnClientUploadStarted="uploadstarted" OnClientUploadError="uploadstarted" Width="523px" UseAbsoluteHandlerPath="false" />
can any one please let me know how to change the file name before uploading ?
Exception details
<Exceptions><Exception><Source>mscorlib</Source><ExceptionDetails>System.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) at System.IO.Path.HasExtension(String path) at AjaxControlToolkit.AjaxFileUploadHelper.Process(HttpContext context) at AjaxControlToolkit.AjaxFileUploadHandler.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)</ExceptionDetails><Message>Illegal characters in path.</Message></Exception></Exceptions>
You have to set/use the file name when you do the fileupload. saveas file. So, run a routine to clear/clean out the provided file name. You can't change/set the file name BEFORE up-loading, but your server side code when doing the complete "event" and "save as" for the file? You have the file name at that point in time in your code behind - and at that point in time you need to clean out the given file name string of funny characters.
Say like this:
Protected Sub AjaxFileUpload1_UploadComplete(sender As Object, e As AjaxControlToolkit.AjaxFileUploadEventArgs) Handles AjaxFileUpload1.UploadComplete
Debug.Print("start of single file process file = " & e.FileName)
Dim strCleanFile As String = TrimNonAscii(e.FileName)
Dim strPhysicalPath = "some path name \" & strCleanFile
AjaxFileUpLoad1.SaveAs(strPhysicalPath)
End Sub
and the trim function? Well, it can be this:
Public Function TrimNonAscii(ByVal value As String) As String
Dim pattern As String = "[^ -~|]+"
Dim reg_exp As Regex = New Regex(pattern)
Return reg_exp.Replace(value, "")
End Function
So I strip out spaces, and a few others with that function.
You can't EVER mess or change the client side file name - for any browser and for any up-load. The reason of course is security. If you could mess/change the client side file name, then while you view cat videos on my site, then I would be up-loading and selecting files with my code - include Excel sheets called password, and documents say called "banking information". So the passed file name is what you get, and what you MUST deal with. You can't mess, nor change the provided file name - browsers don't allow this - as noted this is for reasons of security.
Given that you have to add path names, and often additonal information in that file name, then you have to simply generate your own file name - and if you going to use the passed filename, then you quite much need to clean it out of junk, and then use that.

VBScript FileExists fails consistantly

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

Using a variable from a VBScript in a ASP.Net website

I've been researching this for a majority of the day and can't find the answer. I am relatively new to stackoverflow. Is there a certain etiquette for asking a number of questions (I've asked three in the last few days)?
Anyways,
Here is the code in a codebehind file. It executes a script systeminfo.vbs, and that is working fine. But in the script I have some variables assigned.
Dim WshShell = CreateObject("WScript.Shell")
WshShell.Run("wscript.exe c:\systeminfo.vbs")
vbscript
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
dim osName
osName = objOperatingSystem.Name
Wscript.Echo "OS Name: " & objOperatingSystem.Name
dim osVer
osVer = objOperatingSystem.Version
Wscript.Echo "Version: " & objOperatingSystem.Version
Wscript.Echo "Service Pack: " & _
objOperatingSystem.ServicePackMajorVersion _
& "." & objOperatingSystem.ServicePackMinorVersion
Wscript.Echo "OS Name: " & objOperatingSystem.SizeStoredInPagingFiles
Next
I want to use osName and osVer and put the values into a label on the ASP side.
I understand that osName and osVer are simple examples, but I just need to figure out the concept of putting variables from a VBScript into ASP. My client has multiple VBScripts they use on a daily basis and I need to automate those scripts and produce a report saying if it failed or not.
Thank you for the help.
David,
As a person new to Stack Overflow myself, I was happy to find this very comprehensive FAQ for Stack Exchange sites. See the 3rd question "Is there a limit on how many questions I can ask?" for an answer to your first inquiry.
Regarding the heart of your question, I agree with #Ramhound that using a log file to exchange information between your WSH/VBScript script and your ASP.NET page is a feasible approach.
What you need is the Scripting.FileSystemObject. Here is a comprehensive WSH reference as a downloadable Windows help file.
Hint: as the download page advises at the bottom, to unblock the help page, 1) Right click on script56.chm, 2) Choose Properties, and 3) Click on "Unblock."
You'll find an intro to FileSystemObject under the heading "Script Runtime."
One more suggestion: since you'll be running this script via ASP.NET in a multi-user environment, you may find you'll need to create a log file per user or per page access. If that is the case, you'll need to generate a temporary file name for each log file to avoid name collisions with other log files. To generate your temporary file, see GetTempName in the WSH reference.

Having problem opening/writing to a text file in ASP.NET

I want to write some stats to a text file every time a person loads a page. But every once in awhile I am getting at 'Could Not Open File, Already in use' type of error. I can not 100% replicate this error it is very erratic. My code is
Public Sub WriteStats(ByVal ad_id As Integer)
Dim ad_date As String = Now.Year & Now.Month
Dim FILENAME As String = Server.MapPath("text/BoxedAds.txt")
Dim objStreamWriter As StreamWriter
objStreamWriter = File.AppendText(FILENAME)
objStreamWriter.WriteLine(ad_id & ";" & ad_date)
objStreamWriter.Close()
End Sub
My question is, how can I lock and unlock the file so I stop getting the erratic errors?
Thanks
If two or more requests hit your web server at roughly the same time, they will all try to open the same file. You will need to create unique file names for each request.
Public Sub WriteStats(ByVal ad_id As Integer)
Dim ad_date As String = Now.Year & Now.Month
Dim FILENAME As String = Server.MapPath("text/BoxedAds.txt")
Dim index As Integer
Using fs As New IO.FileStream(FILENAME, IO.FileMode.Append, IO.FileAccess.Write, IO.FileShare.ReadWrite), _
tl As New TextWriterTraceListener(fs)
index = Trace.Listeners.Add(tl)
Trace.WriteLine(ad_id & ";" & ad_date)
Trace.Listeners(index).Flush()
Trace.Flush()
End Using
Trace.Listeners.RemoveAt(index)
End Sub
Three important things here:
Use of IO.FileShare.ReadWrite to allow multiple writers on the file at once.
The Using statement to make sure the stream is closed immediately, even if an exception occurs. This will minimize collisions
The TextWriterTraceListener will create a temp file for your if it can't open the file you request, to make sure the message isn't lost.
You will have to handle the exception and build some handling to re-try writing to the file after a short random interval.
If you get too much contention then it might make more sense to log it to a table in a database and create a process to export to a file (if its still needed)
I haven't had any trouble with short info using:
File.AppendAllText(path, info);
Regarding the comment on it causing locks, from reflector it uses the same options explained very well by Joel. It does not use the trace writer, so it won't output to a temp file in the case of high load / large content causing trouble.
If the info is large, you really want separate files. For high load, I would go with Joel's suggestion and create a temp file, which can be alternatively done by catching the exception on File.AppendAllText, and using the same File.AppeandAllText with a unique filename.

Resources