Re: How can you GetFileInfo for a datasource?
correct me if i am wrong (i am not a .Net developer in any way), but doesn't your .Net code expect you to provide the path to the db as well? or is Session(DBpath) some variable automatically created by .Net? Azadi On 24/06/2010 05:43, John Pullam wrote: This info is not made readily available unless you unlock it. You need access to the database... Open the database Go to tools--Options Check the box under *show* that says *system Objects*. You will notice that several new tables appear in table view with the prefix MSys - MSysAccessObjects, MSysAces, MSysObjects, MSysQueries, MSysRelationships, and there may be a few others depending on your version of Access. Now Go to Tools--Security--User and Group Permissions Select the MSysObjects table and check the box that says Read Data Then... The database is created in a 3rd party application and a copy is sent to my website every 15 minutes, so it isn't practical to change the database itself. I dislike .Net but it certainly was simple there. It took 3 lines: db = Session(DBpath) myDB.mdb Dim myFile as FileInfo = New FileInfo(db) Dim ModDate as Date = myFile.LastWriteTime SELECT UpdateDate FROM MSysObjects /CFQUERY cfdump var=#getSysData# Jim Eisenhauer ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334799 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
I have a datasource that points to an Access database (no editorializing please, I didn't create it). I need to do a GetFileInfo on it to obtain the last modified date. This was pretty easy in .Net (I'm converting it from .Net to CF) but I can't figure out how to do it in CF. GetFileInfo requires an absolute path ... is there a simple way to get the absolute path for a datasource? If it's a registered CF datasource, you can probably get that sort of info using the CF Admin API. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334808 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
I dislike .Net but it certainly was simple there. It took 3 lines: db = Session(DBpath) myDB.mdb Dim myFile as FileInfo = New FileInfo(db) Dim ModDate as Date = myFile.LastWriteTime That makes it look like the path was really just in a Session var in .NET; is that the case? If so, then just do the same in CF: !--- this could be set in Application.cfc or wherever --- cfset session.DBpath = path to the directory / ... cfset db = myDB.mdb / !--- note there's no path info here --- cfdirectory action=LIST directory=#session.DBpath# filter=#db# name=myFile / cfset ModDate = myFile.dateLastModified / ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334805 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
You are correct. I made an assumption that was incorrect and now realize that it was the same issue in .Net. For what its worth, I have decided to base the file location on the relative location from my website root. That is not likely to change while the ISP could always reqyuire me to move the entire website. My final code is: cfset LastUpdated=GetFileInfo(ExpandPath(/) App_Data\MyDatabase.mdb).LastModified ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334809 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
You are correct. I made an assumption that was incorrect and now realize that it was the same issue in .Net. For what it's worth, I have decided to base the file location on the relative location from my website root. That is not likely to change, but the ISP could always require me to move the entire website. My final code is: cfset LastUpdated=GetFileInfo(ExpandPath(/) App_Data\MyDatabase.mdb).LastModified ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334815 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
How can you GetFileInfo for a datasource?
I have a datasource that points to an Access database (no editorializing please, I didn't create it). I need to do a GetFileInfo on it to obtain the last modified date. This was pretty easy in .Net (I'm converting it from .Net to CF) but I can't figure out how to do it in CF. GetFileInfo requires an absolute path ... is there a simple way to get the absolute path for a datasource? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334782 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
If you know the absolute path to the DB You can just set a global var that holds that path. Of course that isn't the most graceful solution, but I'm not sure if there is a way to programmatically determine the absolute path of an Access DB used in a CF datasource. If the DB won't be moving around, then I'd just do something along the lines of what I suggested. HTH Cheers Bryan Stevenson B.Comm. VP Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250.920.8830 e-mail: br...@electricedgesystems.com web: www.electricedgesystems.com Notice: This message, including any attachments, is confidential and may contain information that is privileged or exempt from disclosure. It is intended only for the person to whom it is addressed unless expressly authorized otherwise by the sender. If you are not an authorized recipient, please notify the sender immediately and permanently destroy all copies of this message and attachments. Please consider the environment before printing this e-mail ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334783 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
This info is not made readily available unless you unlock it. You need access to the database... Open the database Go to tools--Options Check the box under *show* that says *system Objects*. You will notice that several new tables appear in table view with the prefix MSys - MSysAccessObjects, MSysAces, MSysObjects, MSysQueries, MSysRelationships, and there may be a few others depending on your version of Access. Now Go to Tools--Security--User and Group Permissions Select the MSysObjects table and check the box that says Read Data Then... Cfquery name=getSysData datasource=cfdocexamples SELECT UpdateDate FROM MSysObjects /CFQUERY cfdump var=#getSysData# Jim Eisenhauer ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334786 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
In your query you might want to SELECT Max(UpdateDate) Sorry =) Jim Eisenhauer ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334787 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
I do know the absolute path but the whole idea was to make it work correctly even if something might change. I was looking for a more elegant solution! ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334788 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
This info is not made readily available unless you unlock it. You need access to the database... Open the database Go to tools--Options Check the box under *show* that says *system Objects*. You will notice that several new tables appear in table view with the prefix MSys - MSysAccessObjects, MSysAces, MSysObjects, MSysQueries, MSysRelationships, and there may be a few others depending on your version of Access. Now Go to Tools--Security--User and Group Permissions Select the MSysObjects table and check the box that says Read Data Then... The database is created in a 3rd party application and a copy is sent to my website every 15 minutes, so it isn't practical to change the database itself. I dislike .Net but it certainly was simple there. It took 3 lines: db = Session(DBpath) myDB.mdb Dim myFile as FileInfo = New FileInfo(db) Dim ModDate as Date = myFile.LastWriteTime SELECT UpdateDate FROM MSysObjects /CFQUERY cfdump var=#getSysData# Jim Eisenhauer ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334789 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: How can you GetFileInfo for a datasource?
I believe you can get all the available datasource info through the admin api. Something like this should spit it all out for you. cfset adminObj = createObject(component,cfide.adminapi.administrator) / cfset isLoggedIn = adminObj.login(yourCFAdminPassword) / cfif not isLoggedIn LOGIN FAILED cfelse cfset dbObj = createObject(component,cfide.adminapi.datasource) / cfdump var=#dbObj.getDatasources()# / /cfscript That would dump all datasources and their settings. I'd assume the access path would be in there since it is one of the settings when creating access datasources. .:.:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -Original Message- From: Bryan Stevenson [mailto:br...@electricedgesystems.com] Sent: Wednesday, June 23, 2010 5:35 PM To: cf-talk Subject: Re: How can you GetFileInfo for a datasource? If you know the absolute path to the DB You can just set a global var that holds that path. Of course that isn't the most graceful solution, but I'm not sure if there is a way to programmatically determine the absolute path of an Access DB used in a CF datasource. If the DB won't be moving around, then I'd just do something along the lines of what I suggested. HTH Cheers Bryan Stevenson B.Comm. VP Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250.920.8830 e-mail: br...@electricedgesystems.com web: www.electricedgesystems.com Notice: This message, including any attachments, is confidential and may contain information that is privileged or exempt from disclosure. It is intended only for the person to whom it is addressed unless expressly authorized otherwise by the sender. If you are not an authorized recipient, please notify the sender immediately and permanently destroy all copies of this message and attachments. Please consider the environment before printing this e-mail ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334790 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: How can you GetFileInfo for a datasource?
Also, I'm sure there is a more elegant way of getting the modified date but a cfdirectory listing of the MDB's parent directory should return a list of files in that directory. One of the returned columns is DATELASTMODIFIED Just throw a filter on the cfdirectory tag to only get the MDB file and voila... hack city. .:.:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -Original Message- From: Bobby Hartsfield [mailto:bo...@acoderslife.com] Sent: Wednesday, June 23, 2010 5:51 PM To: cf-talk Subject: RE: How can you GetFileInfo for a datasource? I believe you can get all the available datasource info through the admin api. Something like this should spit it all out for you. cfset adminObj = createObject(component,cfide.adminapi.administrator) / cfset isLoggedIn = adminObj.login(yourCFAdminPassword) / cfif not isLoggedIn LOGIN FAILED cfelse cfset dbObj = createObject(component,cfide.adminapi.datasource) / cfdump var=#dbObj.getDatasources()# / /cfscript That would dump all datasources and their settings. I'd assume the access path would be in there since it is one of the settings when creating access datasources. .:.:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -Original Message- From: Bryan Stevenson [mailto:br...@electricedgesystems.com] Sent: Wednesday, June 23, 2010 5:35 PM To: cf-talk Subject: Re: How can you GetFileInfo for a datasource? If you know the absolute path to the DB You can just set a global var that holds that path. Of course that isn't the most graceful solution, but I'm not sure if there is a way to programmatically determine the absolute path of an Access DB used in a CF datasource. If the DB won't be moving around, then I'd just do something along the lines of what I suggested. HTH Cheers Bryan Stevenson B.Comm. VP Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250.920.8830 e-mail: br...@electricedgesystems.com web: www.electricedgesystems.com Notice: This message, including any attachments, is confidential and may contain information that is privileged or exempt from disclosure. It is intended only for the person to whom it is addressed unless expressly authorized otherwise by the sender. If you are not an authorized recipient, please notify the sender immediately and permanently destroy all copies of this message and attachments. Please consider the environment before printing this e-mail ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334791 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
On 6/23/2010 2:40 PM, John Pullam wrote: I do know the absolute path but the whole idea was to make it work correctly even if something might change. I was looking for a more elegant solution! CF has file|path several functions that might help you here. expandPath() might do something. It depends on where the database is and what relation that is to the web root path I think. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334792 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: How can you GetFileInfo for a datasource?
On Wed, 2010-06-23 at 17:40 -0400, John Pullam wrote: I do know the absolute path but the whole idea was to make it work correctly even if something might change. I was looking for a more elegant solution! I figured as muchwrap it in a try/catch and handle that eventuality as needed. OR Think this through...if the DB isn't where it is supposed to be, then your datasource and application should completely break. In other words...if it were to move, your code to elegantly handle that event would not work because your app is dead ;-) Cheers Bryan Stevenson B.Comm. VP Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250.920.8830 e-mail: br...@electricedgesystems.com web: www.electricedgesystems.com Notice: This message, including any attachments, is confidential and may contain information that is privileged or exempt from disclosure. It is intended only for the person to whom it is addressed unless expressly authorized otherwise by the sender. If you are not an authorized recipient, please notify the sender immediately and permanently destroy all copies of this message and attachments. Please consider the environment before printing this e-mail ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334793 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm