
Inserting a Delimited Text File into SQL Server
Quote:
>Hi
>Is there any way in VC++, using which i can read and
>insert a delimited
>text file into a database assuming that the data in the
>demilited text
>file maps to the columns in the database table. Your input
>will be
>appreciated.
You can always create SQL insert statements and then run ExcuteSQL()
on them.
Basic scheme:
1. Create a CDatabase linking to your target
2. Open the text file using a CStdioFile or a CFile in text mode
3. Read a line
4. Create a CString "insert into <table> values (<string>)"
5. ExecuteSQL()
6. If not EOF, get next line & goto 4.
You'll need the file to be delimited with single inverted commas,
otherwise you'll need to translate the delimeters.
HTH
Paul.
-------------------------------------------
Expressed opinions are usually my own.
Especially if they're any good (of course).
-------------------------------------------
NB Spam trap in e-mail address
-------------------------------------------