Solved

HOW TO USE  MACROS IN VC TO READ AN ASCIIFILE :URGENT PL

Posted on 2001-06-18
8
230 Views
Last Modified: 2010-04-02
I HAVE AN EXCEL FILE WITH DATA.I WANT TO STORE THESE
RECORDS IN TANDEM TABLE.
I WAS TOLD THAT WE CAN DO SOME TING LIKE THIS:

1.SAVE EXCEL FILE AS AN ASCII

2.WRITE A VC MACRO TO USE THIS ASCII FILE AND

  PREPARE AN INSERT COMMAND.

SO ANY CLUE HOW TO PREPARE THE MACRO???

ITS EXTREMELY URGENT PL

REGARDS
0
Comment
Question by:premchaitanya
8 Comments
 
LVL 2

Expert Comment

by:missionImpossible
Comment Utility
what is a tandem table?
0
 
LVL 30

Expert Comment

by:Axter
Comment Utility
Why do you want to use a MACRO?
Wouldn't a function make more since?

FYI,
When users communicate in all CAPS, some people may interpret that as yelling.
0
 
LVL 1

Author Comment

by:premchaitanya
Comment Utility
hi
Mr.Axter Thanks for the response.

When users communicate in all CAPS, some people may interpret that as yelling.:

sorry it was lit bit urgent so I tried to convey the
urgency.

I cud solve the prob.thanx again


regards


0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
>>I WAS TOLD THAT WE CAN DO SOME TING LIKE THIS...WRITE A VC MACRO TO USE THIS ASCII FILE AND...

This person was either blowing smoke or he/she meant something like this:

lets say you can coax Excel to output a file like:

"Jones","Bill", 1000
"Smith","Tom", 4000
"Johnson","Thomas", 1700

Now imagine that you have some experience programming in C++ so you create small console application that opens a database and creates a recordset (lets call it crsData just for fun).

Now if only you had a sequence of commands like...

  crsData.Open( ...etc... );
  crsData.AddNew();
  crsData.m_sLastName="Jones";
  crsData.m_sFirstName="Bill";
  crsData.m_nWages=1000;
  crsData.Update()

...for each of the lines in the excell data...

All you would need to do is repeat that sequence for each of the items in the Excel output.  You could write a macro that would simplify your task, but it would be easier to just write a function like this...

void AddRec( LPCSTR s1, LPCSTR s2, int n1 )
{
   CRsData crsData( gpcDb );
   crsData.Open( ...etc... );
   crsData.AddNew();
   crsData.m_sLastName="Jones";
   crsData.m_sFirstName="Bill";
   crsData.m_nWages=1000;
   crsData.Update();
}

Now if only you had a sequence of commands like:

AddRec("Jones","Bill", 1000);
AddRec("Smith","Tom", 4000);
etc.

So, you use your text editor to cut the text:
   AddRec(
to the clipboard.  THen you insert that text in front of each of the lines of the excell data.  then add
   );
to the end of each line.

I was going to suggest a macro, but a function is easier to implement.  A macro could be used to "stringize" unquoted text and to do some other handy tasks, shoudl they be needed.

=-=-=-=-=-=-=-=-
Anyway, why not just import the excel data into the Tanndem using standard Tandem tools?

-- Dan
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
oops, fn would look like:

void AddRec( LPCSTR s1, LPCSTR s2, int n1 )
{
  CRsData crsData( gpcDb );
  crsData.Open( ...etc... );
  crsData.AddNew();
  crsData.m_sLastName= s1;
  crsData.m_sFirstName= s2;
  crsData.m_nWages= n1;
  crsData.Update();
}

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
hi premchaitanya,

Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
Comment Utility
hi premchaitanya,

Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
I am sorry to see that Asker has not returned to update and finalize this question.  I am, therefore, force accepting this question.  In the event the Asker returns with additional needs related to this question, please respond and continue the collaboration process.
Thank you,
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

771 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

13 Experts available now in Live!

Get 1:1 Help Now