Hi omega,
First thanks for replying.
You are correct about strSpreadSheet and strSSColumn, the are publicly available values.
Strangely enough in VB5 I didn't need a reference to the table name and with the conversion intColumn and irow is not needed.
Yes there is a fundamental reason I'm not using Excel as you have shown with your code.
This program is a windows service, (Yes with an OCX you could have a windows service in VB5), What I have found in the past and still currently is people using word/excel for daily use of their computer and a background service also using said programs do not mix.
If the user was using excel and the service tried to spawn it's own process to read/update the spreadsheet, then if the user closed their excel the windows service access to the spreadsheet died.
This is why even back in VB5 days this was written not to spawn the application, but use CDO/ADO to do the job which did not affect the normal user of the machine or the service. They were in essence seperated.
I have found how to do what I was after and it's not to bad to do.
After opening the connection the update command is pretty much
Update [table name$] set [column name]=@parameter where [column name]=@parameter
I want the strUpdatedDate to be a string in the spreadsheet so I wrap it in chr(34)'s (double quotes)
The 2 big parts I was originally missing was using the @parameters and then using the oCmd.Parameters.Add to tell it what the parameter equals.
Cheers,
Terry
Main Topics
Browse All Topics





by: omegaomegaPosted on 2009-09-10 at 10:03:25ID: 25302170
Hello, Terry,
There are a couple of things about that code that seem mysterious to me.
I'm not particularly familiar with the OleDB connection strings, so beg your patience if this is obvious. I can't see where strSpreadSheet or strSSColumn are coming from so assume that they are module or global scope variables specified elsewhere. Does one of these include a specification of which Worksheet in the Workbook is the target for the update?
Also, the argument intColumn does not appear to be used in the routine. Is this an oversight, or just a redundancy from the external assignment of strSSColumn?
Finally (and as I'm not very familiar with OleDB, and when all you have is a hammer...) Is there a fundamental reason for not using Excel directly. That is, I would probably have just added a reference in my project to the Excel library and used code similar to that in the snippet. Here I am making wild assumptions about the contents of strSpreadSheet, the name of the sheet that you want to update, and how intColumn is intended to be used. (If multiple frequent updates are required, you could consider moving the creation/quitting of the Excel application and opening/closing the workbook outside of the update routine.
Cheers,
Randy
Select allOpen in new window