Link to home
Start Free TrialLog in
Avatar of premchaitanya
premchaitanya

asked on

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

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
Avatar of missionImpossible
missionImpossible

what is a tandem table?
Avatar of Axter
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.
Avatar of premchaitanya

ASKER

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


>>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
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
hi premchaitanya,

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

-- Dan
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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