Connecting Tech Pros Worldwide Help | Site Map

CSV to SQL by C++

  #1  
Old July 9th, 2009, 09:33 AM
Newbie
 
Join Date: Jul 2009
Posts: 3
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
  #2  
Old July 9th, 2009, 03:10 PM
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,569

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.
How To Use A Database In Your Program
How To Use A Database In Your Program Part II
  #3  
Old July 9th, 2009, 03:25 PM
Newbie
 
Join Date: Jul 2009
Posts: 3

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
  #4  
Old July 9th, 2009, 05:36 PM
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,096
Provided Answers: 3

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.
  #5  
Old July 10th, 2009, 07:40 AM
Newbie
 
Join Date: Jul 2009
Posts: 3

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
  #6  
Old July 10th, 2009, 03:08 PM
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,096
Provided Answers: 3

re: CSV to SQL by C++


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
data transfer from .csv file to sql server 2000 sachin shah answers 2 August 16th, 2007 10:25 AM
.net method that writes .csv file to SQL Server Rasta answers 17 November 21st, 2005 08:36 PM
read csv file to sql Paulb1us@newsgroup.nospam answers 10 November 16th, 2005 07:24 PM
Field Mapping Sample - CSV to Sql Serverusing asp or VB Ashish Kanoongo answers 4 July 19th, 2005 01:52 PM