Im trying to upload pictures using form in ASP classic. Found this piece of code that uses two asp class files written - clsUpload.asp and clsFields.asp.
The upload file looks something like this:
Dim objUpload
Dim strFile, strPath
' Instantiate Upload Class '
Set objUpload = New clsUpload
strFile = objUpload.Fields("file").FileName
strPath = server.mappath("/data") & "/" & strFile
' Save the binary data to the file system '
objUpload("file").SaveAs strPath
Set objUpload = Nothing
But I think the code is trying to save the picture into database using a binary data field. Want I want is to save the picture into the folder and save the filename to a database field.
Any idea how to do it?
Make sure the 'data' folder exists. It will be in the root in this case I think.
You will need a separate script to write the filename to a db.
Related
So far All I have seen is different ways to save an existing image as an attachment to Quality Center (QC). That's fine, but is there a way to directly save an image as an attachment to Quality Center?
So for example, I have set specific areas in my automation framework to capture an image using something like:
browser("title:=.").page("title:=.").CaptureBitmap [fullname,override]
This would require to get the path of the folder in Quality Center, but I'm not sure how, is this possible? I would like to save it under a folder in the Test Plan section of Quality Center.
Ok I got it! You can save it to the temp folder which exists on every machine. Then save it to QC!
Dim oWsh, strTempFolderPath, strFilePathToSave, QCConnection, treeManager
Dim LocalFilePath, Screen1, node, att, atta
Set oWsh = CreateObject("WScript.Shell")
strTempFolderPath = oWsh.ExpandEnvironmentStrings("%Temp%")
strFilePathToSave = strTempFolderPath & "\Test1.png"
browser("title:=.*").page("title:=.*").CaptureBitmap strFilePathToSave,True
Set QCConnection = QCUtil.QCConnection
Set treeManager = QCConnection.TreeManager
' Specify the local path to the file.
LocalFilePath = strFilePathToSave
' Specify the Quality Center path to the desired folder
Screen1 ="Subject\Path to the folder where you want to save it\"
Set node = treeManager.nodebypath(Screen1)
set att = node.attachments
Set atta = att.AddItem(Null)
atta.FileName = LocalFilePath
atta.Type = 1
atta.Post()
Set oWsh = nothing : set QCConnection = nothing : Set treeManager = nothing
Set node = nothing : set att = nothing : set atta = nothing
While the test is running, results are stored in a local temp directory. At the end of the run, the run result is uploaded to QC (and will be re-downloaded if you launch the result viewer to view the run result from QC).
If you put your screenshots underneath that directory (maybe in a separate "screenshots" directory), your screenshots will be part of the run result stored in QC, and thus will be viewable just like other run result entries.
You can get the local temp directory with:
Environment.Value ("ResultDir") & "\Report\".
Everything stored under this directory is considered to be part of the run result and will be uploaded to (and made available in) QC.
I would like to create a LotusScript "script" which would add a specified database to a users workspace. What is the best way to create and , especially, distribute such a script to the users? The users have Microsoft Outlook email and do not use Lotus Notes mail.
You can just call an URL like Notes://Server/Path/Database.nsf from an email you can send to your users.
You can find more details about URL syntax here
In your answer you have two questions: create script and distribute it.
0. LotusScript for adding database icons
You can use NotesUIWorkspace.AddDatabase method to add database icons to a users workspace:
Dim ws As New NotesUIWorkspace
'...
ws.AddDatabase("Your DB0 Server", "Your DB0 FilePath")
ws.AddDatabase("Your DB1 Server", "Your DB1 FilePath")
ws.AddDatabase("Your DB2 Server", "Your DB2 FilePath")
'...
1. Distribution of any script
You can send the Notes URL to users which would run your script. For this you need to create a Form which run your script in the PostOpen event:
Sub Postopen(Source As Notesuidocument)
Dim ws As New NotesUIWorkspace
'Your script here
Call ws.CurrentDocument.Close
End Sub
So, is better to create profile document with such a form and send URL of this document to users:
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim mdoc As NotesDocument
Dim body As NotesMIMEEntity
Dim stream As NotesStream
Dim nname As NotesName
Set db = ses.CurrentDatabase
Set doc = db.GetProfileDocument("YourProfileDocument")
ses.ConvertMIME = False
Set mdoc = db.CreateDocument
mdoc.SendTo = "Your_users_mail#domain.foo"
mdoc.Subject = "Take a look"
Set stream = ses.CreateStream
Set body = mdoc.CreateMIMEEntity
Set nname = ses.CreateName(db.Server)
Call stream.WriteText({Please open this link.})
Call body.SetContentFromText(stream, "text/html;charset=utf-8", ENC_IDENTITY_8BIT)
Call mdoc.Send(False)
In other hand if you want just to add some databases without any computations then you don't need such a script. As suggested by Knut Herrmann:
You could just call an URL like Notes://Server/Path/Database.nsf.
But beware, it does not add database icons to workspace in earlier versions of Lotus Notes (7 or earlier).
I'm trying to make a script that will remove the password protection for a excel (.xls) file but i keep getting the following error when I try to open my workbook:
"Unable to get the Open property of the Workbook class"
My code to open the file is:
sfPath = objArgs(0)
spassword = objArgs(1)
set objExcelFile = CreateObject("Excel.Application")
set objWorkbook = objExcelFile.Workbooks.Open(sfPath, spassword)
Any help would be much appreciated.
Did you read the docs.
You code is passing a string instead of a number specifing to update links or not. Password is the 5th parameter.
expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad, OpenConflictDocument)
I've been looking for a way to get Active Directory's LDAP server url from code running as domain user. The code needs to work correctly in situation with disjoint namespace, if possible. It's unmanaged code so any .NET solutions are not an option unfortunately.
For some reason serverless binding doesn't seem to be working in this case with ADO query returning unhelpful One or more errors occurred during processing of command error when using LDAP://DC=mycompany,DC=local (that's the value of the defaultNamingContext attribute of rootDSE object).
Using the LOGONSERVER and USERDNSDOMAIN environment variables doesn't appear to be an option either because the code also needs to be able to run under the SYSTEM account and there are no such variables there.
Any ideas or hints or specific RTFM advice will be much appreciated.
Update: The DNSHostName attribute of rootDSE seems to be what I need.
I use this Visual Basic Script (VBS). Save the code as .vbs file and use ANSI charset. This script is old, but this can guide you to a better solution.
Set cn = CreateObject("ADODB.Connection")
Set cmd= CreateObject("ADODB.Command")
cn.Provider = "ADsDSOObject;"
cn.open
cmd.ActiveConnection = cn
' Root DSE required to get the default configuration naming context to
' be used as the root of the seach
set objRootDSE = getobject("LDAP://RootDSE")
' Construct the LDAP query that will find all the domain controllers
' in the domain
ldapQuery = "<LDAP://" & objRootDSE.Get("ConfigurationNamingContext") & _
">;((objectClass=nTDSDSA));ADsPath;subtree"
cmd.CommandText = ldapQuery
cmd.Properties("Page Size") = 1000
Set rs = cmd.Execute
do while rs.EOF <> True and rs.BOF <> True
' Bind to the domain controller computer object
' (This is the parent object of the result from the query)
set objDC = getobject(getobject(rs(0)).Parent)
wscript.echo objDC.dNSHostName
rs.MoveNext
Loop
cn.close
The DNSHostName attribute of rootDSE seems to be what I need.
I have an Image object.
I have the Picture type set to linked, so I can change the picture if I want.
I have the Picture property set to the picture name.
I would think that access would use relitive addressing and simple looking in the current directory for the image. But it does not and I get an error telling me it cannot find the picture.
Anyone have a solution? (Other than setting the Picture type to embedded or using the full file address?)
Thanks!
Update:
Tried this:
Private Sub Form_Load()
Dim file As String
file = CurrentDb().Name
file = Replace(file, ".mdb", ".bmp")
Me.Image46.Picture = file
End Sub
It works, except I still get the error message. I click O.K. and it works. Just need the error message to go away.
SOLUTION: Use the above code (or the code posted in the answer below) and then set the 'picture type' to "embedded" and then delete the 'picture' field so that it says "(none)".
Save and run.
It should work.
THANKS!
You could set the property on the forms OnLoad event like this
Me.imgMy_image.picture=getDBPath & “mypicture.bmp”
Here is the getDBPath function
Public Function GetDBPath() As String
Dim strFullPath As String
Dim I As Integer
strFullPath = CurrentDb().Name
For I = Len(strFullPath) To 1 Step -1
If Mid(strFullPath, I, 1) = "\" Then
GetDBPath = Left(strFullPath, I)
Exit For
End If
Next
End Function
Before anyone comments yes I know in access 2000 and above you can use currentproject.path but I’m stuck in the land that time forgot so need that custom function, it still works with later versions of access
Current folder depends of the way you open database in Access. At least, if you open it thru "File-Open", current folder changes to the folder of MDB file. But if you open via double-clicking MDB in explorer, it does not.