Reputation: 62554
i have C# WinForm program that i need to insert fast big data to sql-server.
The sql-server is in cloude server, and the file that i load in local computer.
the file is Text (Tab delimited) in
d:\TEST\TEST.txt and has Full permissions
BAR DES MAK
111 aaa 222
333 bbb 333
.
.
the sql-server table is CatTbl:
BAR nvarchar(250)
DES nvarchar(250)
MAK nvarchar(250)
i try to insert like this:
SQL = @"BULK INSERT CatTbl FROM 'd:\TEST\TEST.txt' WITH (CODEPAGE=1255,FIELDTERMINATOR = '\t')";
Cmd = new SqlCommand(SQL, Conn);
Cmd.ExecuteNonQuery();
Cmd.Dispose();
when i work on local sql-server its works excellent.
but in cloude sql-server i got error:
Cannot bulk load because the file "d:\TEST\TEST.txt" could not be opened. Operating system error code 21(The device is not ready.).
I searched the web and found no answer that solved the problem. I would appreciate some help
Upvotes: 0
Views: 71
Reputation: 1214
So you need to work in the mindset of "where am I right now?". When your're on your computer, D:\ is the drive in your physical box. If you tell the server "I'm loading a bulk file, and its in D:\file.txt", it's not going to look at -your- computer's D:\, its going to look at its -own- D:\, and the file isn't there.
What you need to do is upload the file somewhere first, that the server an access, and then tell the server what path to the file is, relative to him.
Upvotes: 1