Solved

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

Posted on 2001-06-18
8
237 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
ID: 6202310
what is a tandem table?
0
 
LVL 30

Expert Comment

by:Axter
ID: 6202353
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
ID: 6202813
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 49

Expert Comment

by:DanRollins
ID: 6205574
>>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
 
LVL 49

Expert Comment

by:DanRollins
ID: 6205578
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
ID: 6320349
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
ID: 6686549
hi premchaitanya,

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

-- Dan
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6811510
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

726 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