如何从EXCEL将数据写入数据库

来源:百度知道 编辑:UC知道 时间:2024/05/19 04:16:54
我在EXCEL表中导入了一个数据库表,对这个表的字段的数据进行了编辑,可是数据库并没有更新,请问有什么方法么?
我的数据库是ACCESS建立的,机器上并没有安装SQL SERVER

private void Button1_Click(object sender, System.EventArgs e)
{
//选择文件
ofdSelectExcel.Filter = "Excel Files(*.xls)|*.xls";
ofdSelectExcel.RestoreDirectory = true;
if( ofdSelectExcel.ShowDialog() == DialogResult.OK )
{
if ( ofdSelectExcel.FileName.Trim().Length == 0)
{
MessageBox.Show(this,"Please select a excel file first!");
return;
}
else
{
ImportExcelToSqlServer(ofdSelectExcel.FileName.Trim());
}

}
}

//********************************************************
//提取数据
public void ImportExcelToSqlServer(string fileName)
{
if (fileName == null)
{
throw new ArgumentNullException("filename string is null!");
}

if (fileName.Length == 0)
{
throw new ArgumentException(&q