Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / September 2007



Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mike - 24 Sep 2007 03:39 GMT
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
mike - 24 Sep 2007 05:35 GMT
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?
mike - 24 Sep 2007 06:22 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.