Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

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
0
premchaitanya
Asked:
premchaitanya
1 Solution
 
missionImpossibleCommented:
what is a tandem table?
0
 
AxterCommented:
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
 
premchaitanyaAuthor Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

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

-- Dan
0
 
DanRollinsCommented:
hi premchaitanya,

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

-- Dan
0
 
MoondancerCommented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now