Solved

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

Posted on 2001-06-18
8
235 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

831 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