Thread: HELP HELP HELP!!!! Execute SQL statements saved in a text file

  1. #1
    Registered User
    Join Date
    Nov 2005

    HELP HELP HELP!!!! Execute SQL statements saved in a text file

    I have to automate the process of writing data to MS Access database. I have created a program that was executing the dynamically generated Insert queries in a for loop. This was taking very long to execute because of the bulk of the data and the number of for loop executions. I then created a .sql file and wrote all the Insert queries into the file and now plan to execute all the queries of this file as if I was batch executing the sql queries. Using MS Access database is my constraint and I have to use C programming language.

    I have a text file which has about 400,000 INSERT statements. Now I have to read this file from my C program to achieve the goal of executing these INSERT statements in order to populate the desired table. Can you please provide some sample code. May be that'll help. Thank you.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Well you first need to connect to the database. You can do this with something like ADO, or ODBC. Once you've done that, you can just use the ADO or ODBC functions to run the database queries. Here is an article which explains how to connect to an Access database using ODBC.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Mountaintop, Pa
    I've done something similiar to this with SQL Server. Please post a sample of some of the records in your text file just to make sure we're all on the same page.

  4. #4
    Super Moderator Harbinger's Avatar
    Join Date
    Nov 2004
    Lets see how many rules you've broken with your first post.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM