[Webinar] Streamline your web hosting managementRegister Today

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

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
0
vchellam
Asked:
vchellam
  • 3
  • 3
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
 
vchellamAuthor Commented:
Thanks hammerman, let me try this
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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