Importing CSV files RRS feed

  • Question

  • Resources: VB.net Express 2008 & SQL Server 2008 Express from web platform installer on Vista Ultimate.
    Dataset has table named "Stores" with fields that match the CSV file created by Excel 2007.

    Access has a handy dandy table import wizard, but that is not the API I'm using for this project. The connection is standard .\SQLExpress;AttachDbFilename=etc. to my.mdf. Owner: MyNet\User.

    Also, is the SQL 2005 Express toolkit generally usable with 2008? Also, there was SQL Server Management Studio Express in 2005. Is that useable? Is there a toolkit for 2008? I haven't found one.

    This 'usually simple' task is holding up the project. I've seen several solutions in VB.net, ADO, and SQL Server, but so far I'm getting nothing but errors. What works?
    • Edited by DenniSys1 Thursday, December 3, 2009 7:19 PM
    Friday, November 27, 2009 11:25 AM


All replies

  • If you are asking about the IMPORT/EXPORT feature, then you can download 2008 management studio from here http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=08e52ac2-1d62-45f6-9a4a-4b76a8564a2b. AFAIK... 2005 and 2008 tool can not co-exits in the same physical machine.


    MCITP, MCTS, MCDBA,MCP-- Blog : http://experiencing-sql-server-2008.blogspot.com/
    • Marked as answer by DenniSys1 Tuesday, February 24, 2015 5:26 PM
    Friday, November 27, 2009 1:06 PM
  • Not sure how useful MSE08 would be with the programming environment created with web platform installer, which installs Express editions. PowerShell 2.0 looks promising to me.

    My question centered around importing a .csv file created with Excel (or any other).

    I've seen code using SQL, ADO, and VB.net, and was wondering what was 'normal ie best practice - pattern' for doing this task before actually beginning to wire it up in my app, which is being developed in the 'WPI installed' environment.

    Note added with edit: I'm trying to do this programmatically.

    Man Studio 08 Express (the link above) wouldn't install. So I uninstalled SQL 08 and tools and reinstalled with the Web Platform Installer. It worked this time, and the UI looked wonderful to me. All the SQL documentation should get me where I need to be given that the tools I need to work with are present. Getting all this stuff together and operating properly has been a project in itself. Finally I'll be able to integrate what I know with what I'm learning, and quickly move into more sophisticated projects.
    • Edited by DenniSys1 Thursday, December 10, 2009 10:04 PM
    Saturday, November 28, 2009 3:41 PM
  • hi,
    SQLExpres 2008 features the Import Export Wizard which can help a lot, in this circumnstance.. the very same tool is available for SQLExpress 2005 as well, but you have to install a bigger package (http://www.microsoft.com/downloads/details.aspx?familyid=E8AD606A-0960-4EFD-8BD7-B21370C7BE2B&displaylang=en, check the correct service pack level)
    on the other hand, of course you can do that via ADO/Ado.Net and some code..
    and some time you can achieve the very same result via BCP, the bulk copy command line tool utility you are already provided with (http://msdn.microsoft.com/en-us/library/ms162802(SQL.90).aspx)
    http://www.asql.biz - DbaMgr2k - DbaMgr and further SQL Tools
    Saturday, November 28, 2009 5:57 PM
  • If the wizard can import a csv file into my attached db as a table I haven't learned how to do it yet, and I can't find docs that explain how to do that. It apparently did import the data into the SQL <default> database. Remember, I'm using 2008. I'll try the BCP in the 100/Binn. I tried something similar in code like bulk import, but it also returned errors (got nowhere with it). Then I'll tease through the ADO classes and try to find something.

    The import wizard in MS Access is a dream come true. It does everything needed, and does it quickly. If only ...

    Jumping through hoops:
    Running the SQL Import/Export Wizard at the bottom of the page ...
    Note: In SQL Server Express, the option to save the package created by the wizard is not available.
    Reminds me of the 'read the full instructions first,' at the end of the instructions it says not to do the experiment.

    bcp using cmd <run as admin> importcsv.bat
    Here's my batch:
    bcp .\sqlexpress;AttachdbFileName "OurSche.thetable.String" IN "the big list".csv -T -c
    Also tried - bcp IN .\sqlexpress;AttachdbFileName "OurSche.thetable.String" -i "the big list".csv -T -c

    Results for both attempts: error "Copy direction must be either "in", "out", or "format".

    Note added with edit: The BCP help doc reminds me of UNIX man in it's complexity. I'm wondering how difficult it will be to code it into the project, even if I get this solution to work. That is what visual is all about right? There should be a better way with VB.net.

    Thank you.

    Sunday, November 29, 2009 7:33 PM
  • Would someone please give me a working example of how to load an existing table with data from a .csv file using VB 2008 Express and SQL Server 2008 (these have been successfully installed using the Web Platform Installer).

    .\SqlExpress with an attached database

    projects -> ours -> .mdf
    projects -> ours -> ours -> .csv

    I'll skip the details of what I've tried because it's been a problem for more than a week.
    Developed Access and Excel apps (from 2003), but what I'm trying is not working.
    Really need a working example.

    Thank you.

    Thursday, December 3, 2009 7:10 PM
  • Here are a couple of solutions I found - implemented with C#.
    Seems that by now (2009) this (a CSV import / export) would have been made available as a .net class.
    It has been a required task since LOTUS 123 came out.
    Yes, I can remember when haircuts were two bits.

    C# Import and Export at Code Project

    C# A Fast CSV reader at Code Project
    Friday, December 4, 2009 7:21 PM
  • sir? can you kindly give me some codes to import the data of the csv file in an access database?

    cause ive been searching some codes this past two weeks but i can't find any..

    thank you in advance sir,,

    • Edited by raffy_john Friday, June 8, 2012 2:39 PM
    Friday, June 8, 2012 2:35 PM