Connecting Tech Pros Worldwide Forums | Help | Site Map

CSV to SQL by C++

Newbie
 
Join Date: Jul 2009
Posts: 3
#1: Jul 9 '09
Hello people,

I am new to C++ and my first task is to create a program that when run by users, it will import the data in a csv file into sql database. I wonder if it is possible or not and if it is possible, please give me some sample source code.

Much appreciated.

Regards

insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,695
#2: Jul 9 '09

re: CSV to SQL by C++


Well, it is very much possible. I'm assuming you're using Visual C++ and the .NET Framework? Most of our experts in the .NET forum tend to deal with VB.NET and C# though.

So I'm going to link you a few good resources.

Some namespaces you need to study to do this:
System.IO
Make sure to look up StreamReader.
System.Data
Make sure to look up DataSet and DataTable.

Here are some articles on this site that deal with databases. Note that the sample code is in C# / VB.NET, so you might have to do a little translating.
http://bytes.com/topic/net/insights/...e-your-program
http://bytes.com/topic/net/insights/...rogram-part-ii
Newbie
 
Join Date: Jul 2009
Posts: 3
#3: Jul 9 '09

re: CSV to SQL by C++


First of all, thank you very much for your reply and advices.

Yes, I'm trying with both Visual Basic 2008 and Visual C++ 2008. The problem is that I havnet learnt these languages before. As a requirement for a project, I have to create a small application that can import csv file automatically to SQL 2000 (and need to be done in few days). Therefore, If you know any opensource code or demo, please let me know. Thank you in advance.

Regards
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,270
#4: Jul 9 '09

re: CSV to SQL by C++


We cannot do assignments for you, but I can give you a bit more advice.
Start with the first part, you need to be able to parse a CSV into some kind of data structure in your code (I recomend the DataTable object)
Find a way to populate your object with the data contained in the CSV, and you half done.
Newbie
 
Join Date: Jul 2009
Posts: 3
#5: Jul 10 '09

re: CSV to SQL by C++


Hello,

Is there any other reference? I have tried How To Use A Database In Your Program instruction and it seems I got connection but then I cannot run bulkcopy.

Regards
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,270
#6: Jul 10 '09

re: CSV to SQL by C++


You're going to actually have to do it "by hand" so to speak.
Reply