0
쿼리를 삽입하여 내보낼 수 있습니까?파일에서 데이터 저장소로 데이터 복사
"라이브러리의 고급 사용 : 파일에서 데이터 저장소로 데이터 복사"이미지의 페이지 (http://www.filehelpers.net/)에서 정보를 찾을 수 없으며 sql로 내보낼 수 있는지 확인합니다.
쿼리를 삽입하여 내보낼 수 있습니까?파일에서 데이터 저장소로 데이터 복사
"라이브러리의 고급 사용 : 파일에서 데이터 저장소로 데이터 복사"이미지의 페이지 (http://www.filehelpers.net/)에서 정보를 찾을 수 없으며 sql로 내보낼 수 있는지 확인합니다.
이 작동합니다 :
[DelimitedRecord("|")]
public class CustomersVerticalBar
{
public string CustomerID;
public string CompanyName;
public string ContactName;
public string ContactTitle;
public string Address;
public string City;
public string Country;
}
class Program
{
private static string GetInsertSqlCust(object record)
{
CustomersVerticalBar obj = (CustomersVerticalBar)record;
return String.Format("INSERT INTO Customers (Address, City, CompanyName, ContactName, ContactTitle, Country, CustomerID) " +
" VALUES ('{0}' , '{1}' , '{2}' , '{3}' , '{4}' , '{5}' , '{6}' ); ",
obj.Address,
obj.City,
obj.CompanyName,
obj.ContactName,
obj.ContactTitle,
obj.Country,
obj.CustomerID
);
}
static void Main(string[] args)
{
SqlServerStorage storage = new SqlServerStorage(typeof(CustomersVerticalBar));
storage.ServerName = "MYSERVER";
storage.DatabaseName = "Northwind";
// Comment this for Windows Auth
storage.UserName = "shamp00";
storage.UserPass = "whatever";
storage.InsertSqlCallback = new InsertSqlHandler(GetInsertSqlCust);
storage.InsertRecords(CommonEngine.ReadFile(typeof(CustomersVerticalBar), "infile.txt"));
Console.ReadKey();
}
}
내가이 일부 문서가있을 사용 확신 - 그들은 최신의 웹 사이트에서 누락 된 것으로 보인다. FileHelpers 소스 코드에서 단위 테스트를 some more examples으로 볼 수 있습니다.
당신이 시도한 것을 보여주십시오. 코드를 입력하지 않았고 타사 웹 사이트에 링크를 추가했습니다. –