DataSet から DataGrid にデータを表示しました。これから列をSQLテーブルに挿入したいと思います。Dataset で必要な列に変数名を付けて、insert コマンドで呼び出すことはできますか?
ワークシートからの情報を保持する新しい DataSet を作成します。
DataSet objDataset1 = new DataSet();
// Fill the DataSet with the information from the worksheet.
objAdapter1.Fill(objDataset1, "XLData");
// Bind data to DataGrid control.
dgCodeDisp.ItemsSource = objDataset1.Tables[0].DefaultView;
sc.Open();
コマンドを挿入
cmd = new SqlCommand("Insert into Table (Code, v1, v2, ID) values('" +dgCodeDisp + "','" + v1.IsChecked.ToString() + "','" + v2.IsChecked.ToString() + "', '" + txtId.Text + "')", sc);
cmd.ExecuteNonQuery();