For this and the following exercises a MS Access database is used. This is similar in structure to the SQL Server database. The database has the following structure:
Contacts

You can find the database file herewith (zipped).

Develop a command line program 'sqlbatch' which reads a text file with multiple SQL statements and executes these statements. The text file is constructed such that the first line of the connection information (connection string) can be found and then the SQL commands. The SQL statements are each separated by a semicolon (';') is complete (see example).

The result (if any) and the error should be saved to an output file. In SELECT statements is the result output table, otherwise the output will contain the number of modified records. Take in the tabular format, the size of the database column to help.

All SQL statements to be executed ionchi n a separate transaction. Fails a SQL statement, the statements already made can be undone.

Example:

The file 'sqlcmd.txt' contains the following commands:

provider=SQLOLEDB;Integrated Security=SSPI; datasource=127.0.0.1\NetSDK; database=NETBOOK;

SELECT * FROM Contact;

SELECT * FROM Person;

UPDATE Person
SET Name = 'Modified'
WHERE ID = 1;

SELECT * FROM Person;

Calling sqlbatch:
>SqlBatch sqlcmd.txt result.txt