Using ADO, all the records update instead of just 1. What am i doing wrong?

Using ADO, all the records update instead of just 1. What am i doing wrong?

am 24.09.2007 04:39:46 von Mike

Heres the code, I am doing it with excel. I dont normally use
recordsets and I don't understand why all the records are updating at
once. Any ideas?


Set cnnExcel = Server.CreateObject("ADODB.Connection")

'known as a DSN-less connection
cnnExcel.Open "Driver={Microsoft Excel Driver (*.xls)};DBQ=" &
Server.MapPath("calc4.xls") & ";ReadOnly=0;"

Set rstExcel = Server.CreateObject("ADODB.Recordset")

'http://www.w3schools.com/ado/prop_rs_cursortype.asp
'http://www.w3schools.com/ado/prop_rs_locktype.asp

rstExcel.Open "SELECT * FROM TestData WHERE id=1;", cnnExcel, 3, 3

rstExcel.MoveFirst
rstExcel("symbol") = myStock1.symbol
rstExcel("historical_price")= myStock1.historical_price
rstExcel("opening_price") = myStock1.opening_price
rstExcel("pe_ratio")= myStock1.pe_ratio
rstExcel("market_cap")= myStock1.market_cap
rstExcel.Update

Re: Using ADO, all the records update instead of just 1. What am i doing wrong?

am 24.09.2007 06:35:57 von Mike

some more information: it seems tied to the actual excel file. I
tried using a different file that had no formulas etc in it, just
numbers typed into cells, and only the first row of data was changed.
I think excel has some built in "intelligence" for copy down that is
interfering with this. For example, sometimes when you insert a row,
excel will automatically fill in the formula for the inserted cells.
Anyone know a workaround?

Re: Using ADO, all the records update instead of just 1. What am i doing wrong?

am 24.09.2007 07:22:28 von Mike

OK I got it working by creating a new xls file. Apparently excel has
some kind of hidden attributes applied when you do "copy down" or
something. Hopefully someone will find this useful.