The bcp import I wrote last time was a remote import in a sqlserver environment. I made modifications due to project needs. Because in the development project, I encountered the import and export processing of large databases. The customer required the environment to be a web server, a file server and Database server configuration, sqlserver is not allowed to be installed on the web server. When importing large quantities of text data in an environment without bcp, you cannot directly call the cmd command to import. You must reference the external bcp.exe file for data import. When referencing, sqlserver must be Copy the two files bcp.exe and bcp.rll to the web server. I put the following two files in the compant folder of the project:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
code
private void Page_Load(object sender, System.EventArgs e)
{
//Put user code here to initialize the page
Process p = new Process();
p.StartInfo.FileName = Server.MapPath("compant/bcp.exe");
p.StartInfo.UseShellExecute = false;
//@must be added, otherwise special characters will be automatically filtered out
p.StartInfo.Arguments = @"Test..BcpTest in D:temp.txt -S -Usa -P1 -c -t," ;
try
{
p.Start();
p.WaitForExit();
p.Close();
}
catch
{}
}