Solved

How can I add a field to an existing table via ADO recordsets?

Posted on 2006-11-06
3
175 Views
Last Modified: 2013-11-20
I have searched the examples and I would like to add a field to an existing recordset via a connection pointer.
I want the changes to take place permanently also.

Help!

Thanks

Nick
0
Comment
Question by:nickmues
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17882650
You may use SQL statement 'ALTER TABLE tableName .....'

-MAHESH
0
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 125 total points
ID: 17882682
e.g

Adding a new column to an existing table sql statement should be like :

sql = "ALTER TABLE myTable ADD newColumn VARCHAR(255) " ;

-MAHESH
0
 
LVL 1

Expert Comment

by:yogesh28577
ID: 17888306

 
      m_pConnectionAPCLASS.CreateInstance (__uuidof( Connection ));
      m_pConnectionAPCLASS->Open ("PROVIDER=MSDASQL;dsn=lekha;uid=sa;pwd=;database=core;",_bstr_t(L""),_bstr_t(L""),adModeUnknown);

Cstring query ="ALTER TABLE city ADD state VARCHAR(255)";
CComVariant v(0L);
_RecordsetPtr recset;
 recset.CreateInstance(__uuidof(Recordset));
recset=m_pConnectionAPCLASS->Execute(query.AllocSysString (),&v,adOptionUnspecified);
      recset->Close();

in this way you add new coloumn in existing  table
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question