Click to See Complete Forum and Search --> : ADO: Editing a field value in a recordset


Alex Black
May 13th, 1999, 12:08 PM
Hi,

I need to find a record that matches two indexes (orderId and songId), and change the value of one of that records fields (path).

1) whats the best way to find this record? I am opening the recordset using a SQL statement.. "select path from table where orderid = 1 and songid=1", is there an ADO way to Seek?

2) if i do that, how do i edit the field?

here is my code: (which does not work, the field is not updated)



strSQL.Format ("SELECT %s FROM %s WHERE %s = %d AND %s = %d",
"Path",
"Table",
"OrderId",
nOrderId,
"SongId",
nSongId
);

BSTR bstrSQL = strSQL.AllocSysString();

rsPtr->Open (
bstrSQL,
m_db.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText // open as sql
);

ASSERT( !rsPtr->adoEOF ); // we should have a record here

// Write the value of the output filename into the database
_variant_t holder = strOutputFilename;
rsPtr->Fields->GetItem( WAV_PATH_FIELD )->Value = holder;
rsPtr->Close();