Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Import Excel columns in existing SQL database

Import Excel columns in existing SQL database

Scheduled Pinned Locked Moved Visual Basic
databasehelplearning
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vb_jeiss
    wrote on last edited by
    #1

    Hi everyone, would like to import data from an excel table into a SQL table. The problem is that the data from only one Excel table has to be imported into 3 different tables of the same sql-database. So the main problem in my eyes is to associate every excelcolumn to the matching column of one of the trhee diffferent sql-tables. Of course this has to be done manually by the user. I could immagine two listboxes on a form. First-one for the excelcolumns (source) and anotherone for the sqlcolumns(destination) A third listbox could display the columns the user put together. I have already managed to get the excel-data displayed in a datagridview without opening the excelfile with this code.

    oAdapter = New System.Data.OleDb.OleDbDataAdapter( _
    "SELECT * FROM [" & strSheetName & "]", OleDbExcelConn)

    thanks in advance, Jeiss

    T 1 Reply Last reply
    0
    • V vb_jeiss

      Hi everyone, would like to import data from an excel table into a SQL table. The problem is that the data from only one Excel table has to be imported into 3 different tables of the same sql-database. So the main problem in my eyes is to associate every excelcolumn to the matching column of one of the trhee diffferent sql-tables. Of course this has to be done manually by the user. I could immagine two listboxes on a form. First-one for the excelcolumns (source) and anotherone for the sqlcolumns(destination) A third listbox could display the columns the user put together. I have already managed to get the excel-data displayed in a datagridview without opening the excelfile with this code.

      oAdapter = New System.Data.OleDb.OleDbDataAdapter( _
      "SELECT * FROM [" & strSheetName & "]", OleDbExcelConn)

      thanks in advance, Jeiss

      T Offline
      T Offline
      T2102
      wrote on last edited by
      #2

      Why not select * to a data set, get the column names and do it yourself if you know where they should map up to? You could use LINQ or call a bunch of queries to load the data. Alternatively create a stored procedure that selects * into, processes it, and then frees the temporary table if you use one.

      L 1 Reply Last reply
      0
      • T T2102

        Why not select * to a data set, get the column names and do it yourself if you know where they should map up to? You could use LINQ or call a bunch of queries to load the data. Alternatively create a stored procedure that selects * into, processes it, and then frees the temporary table if you use one.

        L Offline
        L Offline
        luccingolo
        wrote on last edited by
        #3

        Hi Ted2102, i suppose that your suggested solutions would do for an excel file with known columnnames and a constant number of columns. But that's not my case. The files i want to be able to import will not always have the same number of columns and their columnames will change from file to file. The only thing these files have in common is that they will contain contact informantions, like name, address, telephonenumber... a.s.o. That's why i wanted to be able to assign the columns of the Excel-file manually (in the listboxes of the form) to the ones of my SQL database. I'm sorry for your efforts in helping me, but in the mean time the situation has changed and i have found a nice code snippet which does the kind of work i need. As a beginner in VB i would like to progress in programming. And that's why i think it would be more important to practice a little bit with the technics used in this snippet. So my new question is now: Does anybody have a link to a good tutorial about learning "List(of Type)" and about "LINQ-queries" for beginners? Any link or code-snippet would be appreciated. Thanks for your help

        T 1 Reply Last reply
        0
        • L luccingolo

          Hi Ted2102, i suppose that your suggested solutions would do for an excel file with known columnnames and a constant number of columns. But that's not my case. The files i want to be able to import will not always have the same number of columns and their columnames will change from file to file. The only thing these files have in common is that they will contain contact informantions, like name, address, telephonenumber... a.s.o. That's why i wanted to be able to assign the columns of the Excel-file manually (in the listboxes of the form) to the ones of my SQL database. I'm sorry for your efforts in helping me, but in the mean time the situation has changed and i have found a nice code snippet which does the kind of work i need. As a beginner in VB i would like to progress in programming. And that's why i think it would be more important to practice a little bit with the technics used in this snippet. So my new question is now: Does anybody have a link to a good tutorial about learning "List(of Type)" and about "LINQ-queries" for beginners? Any link or code-snippet would be appreciated. Thanks for your help

          T Offline
          T Offline
          T2102
          wrote on last edited by
          #4

          Unfortunately, I have not found an ideal reference yet. I only found some documentation on a Microsoft website so far.

          G 1 Reply Last reply
          0
          • T T2102

            Unfortunately, I have not found an ideal reference yet. I only found some documentation on a Microsoft website so far.

            G Offline
            G Offline
            Groufty
            wrote on last edited by
            #5

            Hi Ted2102, never mind. The documentation from Microsoft is not that bad. But there are not really enough easy code examples. They tend to explain everything only once, showing only one example. All that i can tell by now is that working with linq seems to be much more efficient. By the way i discovered a pretty well-filled collection (not a collection in the Visual basic sense) in a separate CodeProject Forum. Last but not least, don't bother about the continuously changing name under my messages. I only experienced little logon problems.... But everything should be fine now. :) Anyway, thanks you for your help.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups