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

This is a discussion on HELP HELP HELP!!!! Execute SQL statements saved in a text file within the C Programming forums, part of the General Programming Boards category; I have to automate the process of writing data to MS Access database. I have created a program that was ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    1

    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
    Location
    California
    Posts
    3,255
    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
    Location
    Mountaintop, Pa
    Posts
    1,059
    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
    Posts
    74
    http://www.catb.org/~esr/faqs/smart-questions.html
    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, 01: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, 04: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, 11:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21