Popular Posts
Export list schema from sharepoint http:// YOUR_SERVER_URL / PATH_TO_SITE_CONTAINING_LIST /_vti_bin/owssvr.dll?Cmd=ExportList&List= {YOUR_LIST_GUID} JSRequest, Get parameters from querystring with javascript in SharePoint Provides method to parse query string, filename, and pathname from URL // Initialize first JSRequest.EnsureSetup(); // Get the current fil... ROBOCOPY: Robust File Copy for Windows -------------------------------------------------------------------------------    ROBOCOPY     ::     Robust File Copy for Windows --------...
Stats
Batch insert using SqlDataAdapter
string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["JobHunter"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connStr))
{
    conn.Open();

    #region
    string JobID = Guid.NewGuid().ToString();
    HashSet<string> JobCategory = new HashSet<string>(new string[] { 
       "Windows 8標準搭載のセキュリティ Windows Defenderとは - トレンドマイクロ",
        "Windows 8対応 パスワードマネージャー Modern UI版 - トレンドマイクロ",
        "Windows 8にもマルウェア対策は必須 - トレンドマイクロ",
        "Windows 8にもWeb脅威対策は必須 - トレンドマイクロ",
        "Windows 8でも、面倒なパスワード入力はしない。 - トレンドマイクロ",
        "Windows 8 最新のセキュリティにも対応 - トレンドマイクロ",
        "Windows 8 もウイルスバスタークラウドで安心! border=",
        "Windows 8 のセキュリティ対策もウイルスバスター クラウド - トレンドマイクロ",
        "Windows 8 Modern UI向け無料アプリ Windows ストアアプリ",
        "Windows 8 Modern UI向け Windows ストアアプリ - トレンドマイクロ",
        "Windows 8 Modern UI向け 3種類のWindows ストアアプリ - トレンドマイクロ"
    });
    #endregion

    using (System.Data.SqlClient.SqlDataAdapter adapter 
        = new System.Data.SqlClient.SqlDataAdapter(@"select top 0 * from JobCategory", conn))
    {
        // add insert command
        adapter.InsertCommand = new SqlCommand(@"insert into JobCategory values(@JobID, @CategoryName);", conn);
        adapter.InsertCommand.Parameters.Add("@JobID", SqlDbType.VarChar, 50, "JobID");
        adapter.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 50, "CategoryName");
        adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;

        DataTable dt = new DataTable();
        adapter.Fill(dt);

        foreach (string name in JobCategory)
        {
            dt.Rows.Add(JobID, name);
        }

        // one-time update
        adapter.UpdateBatchSize = 0;
        adapter.Update(dt);
    }
}
View mobile version