adding a record to table with Datetime field 
Author Message
 adding a record to table with Datetime field

I am using SQL Server 7 and VC.
In order to add a new record to the table I use the code below that
works great.
But, when I have a a DateTime field in the table I don't know how to do
it.
I have a time_t (or Dbtimestamd) variable and I don't know how to
convert it to variant_t (like I do in the code below with float).

// Create an array for the list of fields in
// the Products table.
   COleSafeArray vaFieldlist;
   vaFieldlist.CreateOneDim(VT_VARIANT,2);
// Fill in the field names now.
   long lArrayIndex[1];
   lArrayIndex[0] = 0;
   vaFieldlist.PutElement(lArrayIndex,
   &(_variant_t("PartNumber")));
   lArrayIndex[0] = 1;
   vaFieldlist.PutElement(lArrayIndex,
   &(_variant_t("Price")));
// Create an array for the list of values to go in
// the Products table.
   COleSafeArray vaValuelist;
   vaValuelist.CreateOneDim(VT_VARIANT,2);
// Fill in the values for each field.
   lArrayIndex[0] = 0;
   vaValuelist.PutElement(lArrayIndex,
   &(_variant_t("8TRACK-003")));
   lArrayIndex[0] = 1;
   vaValuelist.PutElement(lArrayIndex,
   &(_variant_t((float)19.95)));

   pRecordSet->AddNew(vaFieldlist, vaValuelist);

Can someone help?
Thanks

Yoni

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 02 Mar 2003 22:16:40 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Insert a record w/ a datetime field using ODBC calls

2. Access violation adding row to empty table with datetime column, heap version only

3. Retrieve a Counter Field after adding a record?

4. Retrieve a Counter Field after adding a record?

5. Adding 1000's of records to a table

6. Problem adding record to blank Access Table using DAO

7. SQLPutData() returns SQL_SUCCESS but no record added to table

8. Notification of new record added to table by another user

9. Crash Adding record if it is the first in table

10. ADO And Adding or Updating Records in SQL Table

11. want to add field to dbase table

12. Add Field to an existed table

 

 
Powered by phpBB® Forum Software