CSV to SQL by C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anhchuong
    New Member
    • Jul 2009
    • 3

    CSV to SQL by C++

    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
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    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.

    Comment

    • anhchuong
      New Member
      • Jul 2009
      • 3

      #3
      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

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        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.

        Comment

        • anhchuong
          New Member
          • Jul 2009
          • 3

          #5
          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

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

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

            Comment

            Working...