문제

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