質問

I know it's possible to do a bulk insert from a file like this:

strSQL = "BULK INSERT Northwind.dbo.[Order Details] 
          FROM 'e:\My Documents\TextFiles\OrderDetails.txt' " & _
         "WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' )"

But I can't seem to find a way to insert an object that's in memory instead. Is this possible?

役に立ちましたか?

解決 3

The solution ended up being to build a COM object in C# that does the bulk insert and then leveraging that COM object in the VB6 project.

他のヒント

The file must be visible from the SQL Server itself and its account must have access rights (if you are using SQL Server):

From http://technet.microsoft.com/en-us/library/ms188365.aspx

BULK INSERT can import data from a disk (including network, floppy disk, hard disk, and so on). 'data_file' must specify a valid path from the server on which SQL Server is running. If data_file is a remote file, specify the Universal Naming Convention (UNC) name. A UNC name has the form \Systemname\ShareName\Path\FileName. For example, \SystemX\DiskZ\Sales\update.txt.

You can use a table variable to populate a temporary table, then use a MERGE statement to process that temp table into the target database.

T-SQL Merge statement docs here http://msdn.microsoft.com/en-us/library/bb510625.aspx

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top