importing data from a text file?

Hello,

i have one problem. i have  a text file containing my data for the records in my ms acces table. i want to import them in my tables using visual C++. does anyone know on this?

venky
vchellamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KangaRooCommented:
The simplest solution is probably by using Access' import functionality.
0
vchellamAuthor Commented:
well i was thinking about it but never got a clear view how to do it? any suggestion which class or fucntion will help me doing this?

venky
0
KangaRooCommented:
It can be pretty simple in Access, depends of the format of the text file.
Please experiment a little, the following means a lot interactive stuff. You can however create an import specification which can later be reused from VBA code to automate the process.

Open a database, from the 'File' menu select 'Get external Data' and select 'import'. The File open dialog appears, select text type (*.csv;*.asc) from the FileType Combo box in the lower left, and navigate to your text file. After selecting it you will be taken to some import wizard.
As mentioned, this is very interactive, but you can store the import-specification that you create with the wizard and later use it from some VBA code (with DoCmd.TransferText)
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

vchellamAuthor Commented:
what is vba? vbscript? vbscript can be useing in visual C++?
0
KangaRooCommented:
No I don't think so. Do you use MS Access?
0
hammermanCommented:
I don't know if you can use the following info (the code is a little dinosaurish)...but I used it to read a text file, select data from the file, and store that data in different fields (m_P_number &  m_Disposition )in a (previously created) Access database.

CDatarecoverView::OnRecoverButton()
{
 FILE *input;
 char letter;
 int flag = 0, count=0, i = 0;
 char pnumber[7] = {NULL};

      
 if ((input = fopen(m_File, "r")) == NULL)
 AfxMessageBox("Error Opening Input File!");

 else      {

 while ((letter = fgetc(input))) != EOF){

if (letter == 'P'){
  pnumber[0] = letter;

 for(count=1; count<7; count++){
  pnumber[count] = fgetc(input);
  flag++;
 }  //End for...
}  //End if...

 m_pSet->AddNew();
 m_pSet->m_P_number = pnumber;

if (letter == 'B' & (flag > 4)){
 m_pSet->m_Disposition = letter;
 m_pSet->Update();
 flag = 0;

}  //End if...
}  // end while ((letter = fgetc(input))) != EOF)

}  // end else

fclose(input);

}  // end void CDatarecoverView::OnRecoverButton()
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vchellamAuthor Commented:
Thanks hammerman, let me try this
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.