Results 1 to 4 of 4

Thread: Quick question about SQLBulkCopy

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Question Quick question about SQLBulkCopy

    Hello,

    I have a VB.NET program that uses SQL Express on a pc tablet. I need to get the data from the device and insert them on a PC in the office with SQL Express. So I read about SQLBulkCopy and it sounds like that will work. It said the data source can be different types so what type should I put the data in from the tablet. I need to export the data to a file. Should it be a csv or what format? I have all different field types such as varchar, int, bit, etc, being used in the tables I need to export.

    Thanks,

    Warren

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,192

    Re: Quick question about SQLBulkCopy

    If you're talking about using the SqlBulkCopy class in a VB.NET app then you need to import your data into a DataTable. How you do that is completely irrelevant to the actual bulk copy operation. You just have to make sure that that DataTable has a schema that matches your database and that the data is valid, e.g. all values are provided for non-nullable columns.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,883

    Re: Quick question about SQLBulkCopy

    IT doesn't even need to be a file. As jmc noted, you just need the data in a DataTable. So if you have the data in a local database, you can simply select from your local database filling a datatable, then use the SQLBulkCopy to stuff it into SQL Server.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,876

    Re: Quick question about SQLBulkCopy

    Do you need to do this in .Net code? SQLCMD is a command prompt utility for doing all kinds of SQL interaction.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width