Add new column into the table using ADO not ADOX

C

coder

Hi Everybody,



I want to add new column 'firstaname' into the existing table "geo" already
two columns namely

'salcode' 'lastname'.I run the following code it runs without error, when i
opened the database see the structure of table, i didn't find new column in
the table "geo"



here is the snippet of code what i am using.






/* FieldsPtr fields;
FieldPtr field;*/

_bstr_t name("firstname1");

//pRstTitles->get_Fields(&fields);

/* pRstTitles->Fields->Append(name, adVarChar , 15, adFldUnspecified);
pRstTitles->CursorLocation = adUseClient ;
pRstTitles->LockType = adLockOptimistic ;
pRstTitles->Open("geo",
_variant_t((IDispatch *)pConnection,true), adOpenStatic,
adLockOptimistic, adCmdTable);*/





pls pls pls help me out .. I need it very urgently.
 
D

Douglas J. Steele

The only way you can use ADO to add a column to a table is if you run DDL

ALTER TABLE geo
ADD COLUMN firstaname Text(15)

All your code does is add a field to a recordset based on the table, not to
the table itself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top