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
Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

861 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