Solved

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

Posted on 2006-11-06
3
169 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
Powershell based monitoring system 2 127
Get filename and folder into excel 7 67
Replacement selected text 2 47
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now