超短线看什么指标选股:我从文本文件中提取数据到一个DataSet里,怎么样才能把这个DataSet里面的数据插入到sql数据库里

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 09:01:02
我从文本文件中提取数据到一个DataSet里,怎么样才能把这个DataSet里面的数据插入到sql数据库里,不要一条一条的遍历插入,有什么办法一次插入呢?
能不能详细点呢?我的代码是:
//数据库数据更新(传DataSet和DataTable的对象)
public void UpdateDs(DataSet changedDs, string tableName)
{
try
{
ConnDb();
dad = new SqlDataAdapter(sql, ConnStr);
sqlCmdBuilder = new SqlCommandBuilder(dad);
dad.MissingSchemaAction = MissingSchemaAction.AddWithKey;
changedDs.Merge(changedDs);
dad.Update(changedDs, tableName);
changedDs.AcceptChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "数据库更新失败");
throw;
}
}

DataSet.Updata